Skip to content

Instantly share code, notes, and snippets.

@polycarpou
Created October 9, 2013 00:28
Show Gist options
  • Save polycarpou/6894180 to your computer and use it in GitHub Desktop.
Save polycarpou/6894180 to your computer and use it in GitHub Desktop.
Domain Model for a School day - 12 homework
class School
attr_accessor :roster
def initialize(school_name)
@roster = {}
end
def add_student(student_name, grade)
self.roster[grade] ||= []
self.roster[grade] << student_name
end
def grade(grade_value)
self.roster[grade_value]
end
def sort
self.roster.keys.each do |grade|
self.roster[grade].sort!
end
self.roster
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment