lukew244 / Ruby-class-methods

Ruby class methods workshop.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Class methods

Learning objectives

  • Understand that class method belongs to a class object
  • Understand how class methods are used in the Builder pattern
  • Understand how class methods are used to persist information
  • Understand why class methods should not be overused

Assignment

  • Investigate object properties of classes in pry;
  • Read through team.rb. Understand the usage of the class method as Builder;
  • Implement build method in the Team class to build a team from a list of players. The method should validate passed arguments: a roller derby team should have a jammer and 4 blockers one of whom is a pivot;
  • Refactor the Team class to store team name in a class method;

Further reading

  • "Design Patterns", Chapter 3, Builder
  • "Design Patterns in Ruby", Chapter 14
  • This blog post

These two chapters cover the Builder pattern, but not in relation to class methods.

About

Ruby class methods workshop.


Languages

Language:Ruby 100.0%