summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/band.rb5
-rw-r--r--lib/contact.rb12
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/band.rb b/lib/band.rb
index 61efcee..760274b 100644
--- a/lib/band.rb
+++ b/lib/band.rb
@@ -8,6 +8,9 @@ class Band
def initialize(params = nil)
@errors = []
+ @contact = Contact.new
+ @members = []
+ @songs = []
if params
@name = params['name']
@@ -18,14 +21,12 @@ class Band
@contact = Contact.new(params['contact'])
- @members = []
if params['members']
params['members'].each do |k, m|
@members << Member.new(m)
end
end
- @songs = []
if params['songs']
params['songs'].each do |k, s|
@songs << Song.new(s)
diff --git a/lib/contact.rb b/lib/contact.rb
index 1e6ba4b..0d87012 100644
--- a/lib/contact.rb
+++ b/lib/contact.rb
@@ -1,10 +1,12 @@
class Contact
attr_reader :name, :addr, :phone, :email
- def initialize(params)
- @name = params['name']
- @addr = params['addr']
- @phone = params['phone']
- @email = params['email']
+ def initialize(params = nil)
+ if params
+ @name = params['name']
+ @addr = params['addr']
+ @phone = params['phone']
+ @email = params['email']
+ end
end
end