Class: BoxOffice::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/boxoffice/cli.rb

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
# File 'lib/boxoffice/cli.rb', line 3

def call
  list_movies
  options
  goodbye
end

#goodbyeObject



37
38
39
# File 'lib/boxoffice/cli.rb', line 37

def goodbye
  puts "Thank you for using the boxoffice-cli-gem!"
end

#list_moviesObject



9
10
11
12
13
14
15
16
# File 'lib/boxoffice/cli.rb', line 9

def list_movies
  puts "Today's Top 3 Box Office Movies:"
  puts " "
  @top_three =  BoxOffice::Movies.today
  @top_three.each.with_index(1) do |movie, i|
   puts "#{i}. '#{movie.name}' - Rotton Tomatoes: #{movie.rt_score}"
  end
end

#optionsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/boxoffice/cli.rb', line 18

def options
  input = nil
  while input != "exit"
    puts " "
    puts "Type in the number of the movie you'd like more information on. Type 'list' to see today's top 3 box office movies again. Type 'exit' to quit at any time."
    input = gets.strip
    if input.to_i > 0 && input.to_i < 4
      movie = @top_three[input.to_i - 1]
      puts "'#{movie.name}'"
      puts " "
      puts "Rotton Tomatoes: #{movie.rt_score}"
      puts "Audience Score: #{movie.a_score}"
      puts "#{movie.cc}"
    elsif input == "list"
      list_movies
    end
  end
end