1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class Member attr_reader :name, :instrument, :age def initialize(params = nil) if params @name = params['name'] @instrument = params['instrument'] @age = params['age'].to_i else @name = '' @instrument = '' @age = 0 end end def to_s [name, instrument, age].join(', ') end end