diff --git a/config/database.yml.sample b/config/database.yml.sample deleted file mode 100644 index 44360d7..0000000 --- a/config/database.yml.sample +++ /dev/null @@ -1,6 +0,0 @@ -host: 'localhost' -adapter: 'postgresql' -database: 'watchman' -username: XXXXXXX -encoding: 'utf8' -pool: 5 diff --git a/db/seed.rb b/db/seed.rb index 3c028ff..ec262d9 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -3,5 +3,8 @@ Show.delete_all amc = Network.create(name: "AMC") nbc = Network.create(name: "NBC") +cbs = Network.create(name: "CBS") Show.create(name: "Mad Men", day_of_week: "Sunday", hour_of_day: 22, network: amc) Show.create(name: "Community", day_of_week: "Thursday", hour_of_day: 20, network: nbc) +Show.create(name: "Person of Interest", day_of_week: "Thursday", hour_of_day: 20, network: cbs) +Show.create(name: "Criminal Minds", day_of_week: "Wednesday", hour_of_day: 20, network: cbs) diff --git a/models/show.rb b/models/show.rb index 6c82f65..f7fc0b3 100644 --- a/models/show.rb +++ b/models/show.rb @@ -4,6 +4,6 @@ class Show < ActiveRecord::Base validates_presence_of :name def to_s - "#{name} airs at #{hour_of_day}:#{day_of_week}:00 on #{network} " + "#{name} airs at #{hour_of_day}:00 on #{day_of_week}" end end diff --git a/watchman.rb b/watchman.rb index ebe9be4..38df26b 100644 --- a/watchman.rb +++ b/watchman.rb @@ -13,3 +13,16 @@ puts show end end + +def find_show + dow = { 1 => "Monday", 2 => "Tuesday", 3 => "Wednesday", 4 => "Thursday", 5 => "Friday", 6 => "Saturday", 7 => "Sunday" } + puts "Pick a day of week: Use 1 for Monday ... 7 for Sunday" + user_pick = dow.fetch( gets.to_i ) { puts "sorry, not found" } + + Network.all.each do |network| + network.shows.each { |show| puts show if show.day_of_week == user_pick } + end + +end + +find_show \ No newline at end of file