Class: NowShowing::CLI
- Inherits:
-
Object
- Object
- NowShowing::CLI
- Defined in:
- lib/now_showing/cli.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
2 3 4 5 |
# File 'lib/now_showing/cli.rb', line 2 def call welcome end |
#goodbye ⇒ Object
120 121 122 123 |
# File 'lib/now_showing/cli.rb', line 120 def goodbye puts "" puts "Thank you for using Now Showing gem. Bye!" end |
#menu ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/now_showing/cli.rb', line 16 def input = nil print "Please enter the number for the option you would like to see or exit to quit gem." input = gets.strip.downcase if input == "1" top elsif input == "2" opening elsif input == "exit" goodbye else print "Please enter a valid option of 1/2 or exit. " end end |
#opening ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/now_showing/cli.rb', line 79 def opening NowShowing::Opening.scrape #puts list of top ten movies puts "Movies opening this week are:" puts " Title " puts '' NowShowing::Opening.all.each_with_index do |movie,index| puts "#{index+1}. #{movie.name.ljust(35)}" end puts "" print "Please select a movie by number you would like more info on or you can return at exit. " input = nil while input != "exit" input = gets.strip.downcase #if (1..NowShowing::Opening.all.length).to_a.include?(input.to_i) if input.to_i.between?(1, NowShowing::Opening.all.count) movie = NowShowing::Opening.all[input.to_i-1] puts " -------------------------------------------------------------------------------- " puts "#{movie.name}" puts "" puts "Metascore: #{movie.}" puts "" puts "#{movie.about} " puts "" puts " -------------------------------------------------------------------------------- " puts "" print "Please select another movie you would like more info on or you can return at exit. " elsif input == "return" # exits this loop and clears array to reset it input = "exit" NowShowing::Opening.reset self.call elsif input == "exit" goodbye else print "Please enter valid a option." end end end |
#top ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/now_showing/cli.rb', line 33 def top #Scrapes imdb.com for top ten movies and create array of instances of movies. NowShowing::Show.scrape_now_showing #puts list of top ten movies puts "The current top ten movies are:" puts " Title | Gross | Weekend " puts '' NowShowing::Show.all.each_with_index do |movie ,index| puts "#{index+1}. #{movie.name.strip.ljust(40)}| #{movie.gross.ljust(15)}| #{movie.weekend.ljust(15)}" # format text using .ljust end #puts option to show extended info about movie by inputing movie number input = nil puts "" print "Would you like more info about a movie if so enter the movie number else type exit/return. " while input != "exit" input = gets.strip.downcase if input.to_i.between?(1, 10) movie = NowShowing::Show.all[input.to_i-1] #scrapes addtional movie info if not already scraped NowShowing::Show.more_info(movie) if movie.about == nil || movie. == nil puts " -------------------------------------------------------------------------------- " puts "#{movie.name}" puts "" puts "Metascore: #{movie.}" puts "" puts "#{movie.about} " puts " -------------------------------------------------------------------------------- " puts "" print "Please select another movie you would like more info on or you can return at exit. " elsif input == "return" # exits this loop and clears array to reset it input = "exit" NowShowing::Show.reset self.call elsif input == "exit" goodbye else print "Please enter valid a option. " end end end |
#welcome ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/now_showing/cli.rb', line 7 def welcome puts "Welcome to Now Showing" puts "What would you like to found out about?" puts "" puts "1. Top ten movies in theathers now" puts "2. Movings opening this week" puts "" end |