blob: 61efceecc4b0d812b52e98ef528bf86affd5de1b (
plain) (
tree)
|
|
require_relative 'contact'
require_relative 'member'
require_relative 'song'
class Band
attr_reader :name, :city, :website, :label, :short_bio, :contact, :members, :songs
attr_reader :errors
def initialize(params = nil)
@errors = []
if params
@name = params['name']
@city = params['city']
@website = params['website']
@label = params['label']
@short_bio = params['shortbio']
@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)
end
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
|