diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/member.rb | 14 | ||||
-rw-r--r-- | lib/song.rb | 14 |
2 files changed, 17 insertions, 11 deletions
diff --git a/lib/member.rb b/lib/member.rb index 0fb69b5..598b5f4 100644 --- a/lib/member.rb +++ b/lib/member.rb @@ -1,10 +1,16 @@ class Member attr_reader :name, :instrument, :age - def initialize(params) - @name = params['name'] - @instrument = params['instrument'] - @age = params['age'].to_i + 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 diff --git a/lib/song.rb b/lib/song.rb index 93172f2..482834e 100644 --- a/lib/song.rb +++ b/lib/song.rb @@ -1,13 +1,13 @@ class Song attr_reader :title, :time, :isrc, :composers, :performers, :notes - def initialize(params) - @title = params['title'] - @time = params['time'] - @isrc = params['isrc'] - @composers = params['composers'].split("\n") - @performers = params['performers'].split("\n") - @notes = params['notes'] + def initialize(params = nil) + @title = params ? params['title'] : '' + @time = params ? params['time'] : '' + @isrc = params ? params['isrc'] : '' + @composers = params ? params['composers'].split("\n") : [] + @performers = params ? params['performers'].split("\n") : [] + @notes = params ? params['notes'] : '' end def to_s |