Class: TopBox::CLI
- Inherits:
-
Object
- Object
- TopBox::CLI
- Defined in:
- lib/top_box/cli.rb
Instance Method Summary collapse
Instance Method Details
permalink #call ⇒ Object
[View source]
3 4 5 6 7 8 |
# File 'lib/top_box/cli.rb', line 3 def call puts 'Current Top Box Office Movies by imdb.com' TopBox::Movie.new_from_collection(Scraper.scrape_movie_list) list_movies end |
permalink #list_movies ⇒ Object
[View source]
10 11 12 13 14 15 16 17 |
# File 'lib/top_box/cli.rb', line 10 def list_movies #parse array of movie objects to output list TopBox::Movie.all.each do |m| puts "#{m.num}. #{m.title}" puts "Week #{m.weeks_in_theater}, Total gross: #{m.total_gross}" puts '--------------' end end |
permalink #menu ⇒ Object
[View source]
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/top_box/cli.rb', line 19 def #takes user input to provide more information puts "Enter number of a movie from the list to view a plot summary, 'list' to see the list of movies again or 'exit' to quit" x = gets.strip.downcase num = x.to_i if num > 0 and num < TopBox::Movie.all.length + 1 m = TopBox::Movie.all[num-1] if !m.summary m.get_movie_details end puts "---------" puts "#{m.title}, #{m.runtime}" puts "Metascore: #{m.}/100" puts "---------" puts m.summary puts "---------" (m) elsif x=='exit' exit elsif x=='list' list_movies else puts "invalid entry" end end |
permalink #review_menu(m) ⇒ Object
[View source]
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/top_box/cli.rb', line 48 def (m) #asks if user would like to see reviews for specific movie puts "Would you like to see some critic reviews from this movie? y/n" x=gets.strip.downcase if x=='y' m.get_reviews puts "--------------" m.reviews.each{ |review| puts "Score: #{review.score}/100" if review.=='' puts "From: #{review.publication}" else puts "From: #{review.publication}, by #{review.}" end puts review.summary puts "--------------" } else x=='n' end end |