diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/db/seed.rb b/db/seed.rb index 3c028ff..ae356da 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: "Law and Order:SVU", day_of_week: "Thursday", hour_of_day: 22, network: nbc) +Show.create(name: "How I met Your Mother", day_of_week: "Monday", hour_of_day: 20, network: cbs) diff --git a/models/show.rb b/models/show.rb index 6c82f65..04767cd 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} " + "#{id.inspect}: #{name} airs at #{day_of_week}:#{hour_of_day}:00 on #{network} " end end diff --git a/watchman.rb b/watchman.rb index ebe9be4..c6dda17 100644 --- a/watchman.rb +++ b/watchman.rb @@ -13,3 +13,35 @@ puts show end end + +def search_again + while true do + puts "Search Again (Y/N)" + answer = gets.upcase[0] + if answer == "Y" + find_show + else + break + end + end +end + + +def find_show + puts "What day do you want to watch TV?" + day = gets.chomp + + shows = Show.find(:all, :conditions => {:day_of_week => day}) + + unless shows.empty? + shows.each do |show| + puts show + end + else + puts "There was nothing found for #{day}" + end + search_again +end + +find_show +