Class: CommandLineInterface
- Inherits:
-
Object
- Object
- CommandLineInterface
- Defined in:
- lib/cli.rb
Instance Method Summary collapse
- #invalid ⇒ Object
- #list_menu ⇒ Object
- #list_show ⇒ Object
- #run ⇒ Object
- #show_info(show) ⇒ Object
- #show_menu ⇒ Object
Instance Method Details
#invalid ⇒ Object
59 60 61 |
# File 'lib/cli.rb', line 59 def invalid puts "\nInvalid command please enter a valid command." end |
#list_menu ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cli.rb', line 17 def puts "If you would like get more information about a specific show enter their index number, \ntype 'list' to show the list of today's episode, or 'exit'" input = gets.strip.downcase if input.to_i.between?(1, Show.all.count) show_info(Show.all[input.to_i-1]) elsif input == "list" list_show elsif input == "exit" else invalid end end |
#list_show ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/cli.rb', line 9 def list_show puts "\nToday's new episodes are:" Show.all.uniq.each_with_index do |show, index| puts "#{index+1}. #{show.name}" end puts "" end |
#run ⇒ Object
2 3 4 5 6 7 |
# File 'lib/cli.rb', line 2 def run puts "\nLoading today's new TV episodes. \n(This might take a couple of minutes)" Scrapper.list_scrapper list_show end |
#show_info(show) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cli.rb', line 34 def show_info(show) puts "\n#{show.name}" puts "\nSummary: #{show.summary}" puts "\nGenre: #{show.genre.join(", ")}" puts "Channel: #{show.channel}" puts "Showtime: #{show.showtime}" puts "Current Season: #{show.season}" puts "New Episode: #{show.episode}. #{show.episode_name}" puts "" end |
#show_menu ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cli.rb', line 45 def puts "Type 'list' to show the list of today's episode, or 'exit'" input = gets.strip.downcase if input == "list" list_show elsif input == "exit" else invalid end end |