-
Notifications
You must be signed in to change notification settings - Fork 27
Panda & Tiger level completed #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,14 +2,48 @@ | |
| require 'bundler/setup' | ||
|
|
||
| require "./db/setup" | ||
| Dir.glob('./models/*').each { |r| require r} | ||
| Dir.glob('./models/*').each { |r| require r } | ||
| require "./db/seed" | ||
|
|
||
| puts "There are #{Show.count} in the database" | ||
| WEEK_DAY = { | ||
| '1' => "Monday", | ||
| '2' => "Tuesday", | ||
| '3' => "Wednesday", | ||
| '4' => "Thursday", | ||
| '5' => "Friday", | ||
| '6' => "Saturday", | ||
| '7' => "Sunday" | ||
| } | ||
|
|
||
| def select_day | ||
| puts "-" * 80 | ||
| puts "Which week day do you want watch TV shows?" | ||
| puts "1: Monday, 2: Tuesday, 3: Wednesday, 4: Thursday, 5: Friday, 6: Saturday, 7: Sunday or Q: Quit" | ||
| STDOUT.write "Select a day [1~7 or Q]:" | ||
| gets.chomp | ||
| end | ||
|
|
||
| while true | ||
| day = select_day | ||
|
|
||
| if day.upcase == 'Q' | ||
| puts "Goodbye!" | ||
| break | ||
| end | ||
|
|
||
| unless day.match(/^[1-7]$/) | ||
|
||
| puts "No such day: '#{day}', please select again!" | ||
| next | ||
| end | ||
|
|
||
| sday = WEEK_DAY[day] | ||
|
||
| shows = Show.where(day_of_week: sday) | ||
|
|
||
| if shows.empty? | ||
| puts "No shows on #{sday}" | ||
| else | ||
| puts "Shows on #{sday}:" | ||
| shows.each {|show| puts show} | ||
| end | ||
|
|
||
| Network.all.each do |network| | ||
| puts "Shows airing on #{network}" | ||
| network.shows.each do |show| | ||
| puts show | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably recommend to either stick with puts or STDOUT.