From 1c48f48073e33875650b687ced05a51e0fd7f7d3 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 3 Oct 2015 17:41:27 +0200 Subject: Add route to handle submitted form. --- lib/band.rb | 26 ++++++++++++++++++++++++++ lib/contact.rb | 10 ++++++++++ lib/member.rb | 9 +++++++++ lib/song.rb | 11 +++++++++++ 4 files changed, 56 insertions(+) create mode 100644 lib/band.rb create mode 100644 lib/contact.rb create mode 100644 lib/member.rb create mode 100644 lib/song.rb (limited to 'lib') diff --git a/lib/band.rb b/lib/band.rb new file mode 100644 index 0000000..44d1e7c --- /dev/null +++ b/lib/band.rb @@ -0,0 +1,26 @@ +require_relative 'contact' +require_relative 'member' +require_relative 'song' + +class Band + attr_reader :name, :city, :website, :label, :short_bio, :contact, :members, :songs + + def initialize(params) + @name = params['name'] + @city = params['city'] + @website = params['website'] + @label = params['label'] + @short_bio = params['shortbio'] + @contact = Contact.new(params['contact']) + + @members = [] + params['members'].each do |k, m| + @members << Member.new(m) + end + + @songs = [] + params['songs'].each do |k, s| + @songs << Song.new(s) + end + end +end diff --git a/lib/contact.rb b/lib/contact.rb new file mode 100644 index 0000000..1e6ba4b --- /dev/null +++ b/lib/contact.rb @@ -0,0 +1,10 @@ +class Contact + attr_reader :name, :addr, :phone, :email + + def initialize(params) + @name = params['name'] + @addr = params['addr'] + @phone = params['phone'] + @email = params['email'] + end +end diff --git a/lib/member.rb b/lib/member.rb new file mode 100644 index 0000000..c67915a --- /dev/null +++ b/lib/member.rb @@ -0,0 +1,9 @@ +class Member + attr_reader :name, :instrument, :age + + def initialize(params) + @name = params['name'] + @instrument = params['instrument'] + @age = params['age'].to_i + end +end diff --git a/lib/song.rb b/lib/song.rb new file mode 100644 index 0000000..c045ed2 --- /dev/null +++ b/lib/song.rb @@ -0,0 +1,11 @@ +class Song + attr_reader :title, :time, :composers, :performers, :notes + + def initialize(params) + @title = params['title'] + @time = params['time'] + @composers = params['composers'] + @performers = params['performers'] + @notes = params['notes'] + end +end -- cgit v1.2.3