summaryrefslogtreecommitdiffstats
path: root/lib/band.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/band.rb')
-rw-r--r--lib/band.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/band.rb b/lib/band.rb
index 22778ff..49180d8 100644
--- a/lib/band.rb
+++ b/lib/band.rb
@@ -4,8 +4,10 @@ require_relative 'song'
class Band
attr_reader :name, :city, :website, :label, :short_bio, :contact, :members, :songs
+ attr_reader :errors
def initialize(params)
+ @errors = []
@name = params['name']
@city = params['city']
@website = params['website']
@@ -20,8 +22,21 @@ class Band
end
@songs = []
- params['songs'].each do |k, s|
- @songs << Song.new(s)
+ if params['songs']
+ params['songs'].each do |k, s|
+ @songs << Song.new(s)
+ end
+ end
+ end
+
+ def valid?
+ validate!
+ errors.length == 0
+ end
+
+ def validate!
+ if @songs.length <= 0
+ errors << "Du må ha med minst én låt!"
end
end
end