Class: LatestTomatoes::CLI

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

Instance Method Summary collapse

Instance Method Details

#adiosObject



53
54
55
# File 'lib/latest_tomatoes_cli_gem/cli.rb', line 53

def adios
  puts "\nBye! Check back next week for new releases.\n"
end

#callObject



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

def call
    new_movies
    input_1
    adios
end

#input_1Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/latest_tomatoes_cli_gem/cli.rb', line 26

def input_1
  input = nil
  while input != "exit"
  puts "    Type the number of a movie to view more information about it, or back to see the list again, or exit:\n    DOC\n    input = gets.strip.downcase\n    if input.to_i > 0 && input.to_i < 31 # not an integer\n        @movies[input.to_i-1][:tomatoScore] != nil ? tmeter = \"\#{@movies[input.to_i-1][:tomatoScore]}%\" : tmeter = \"N/A\"\n        puts <<-DOC.gsub /^\\s+/, \"\"\n        -------------\n        \#{@movies[input.to_i-1][:title]} - tomato meter: \#{tmeter}\n        Actors: \#{@movies[input.to_i-1][:actors].join(\", \")}\n        MPAA: \#{@movies[input.to_i-1][:mpaaRating]}\n        \#{@movies[input.to_i-1][:synopsis]}\n        http://www.rottentomatoes.com\#{@movies[input.to_i-1][:url]}\n        -------------\n        DOC\n\n    elsif input.to_i > 30\n      puts \"Oops, there are only 30 movies listed. Enter a number between 1-30.\"\n    elsif input == \"back\"\n        new_dvds\n    end  \n  end \nend\n".gsub /^\s+/, ""

#new_dvdsObject



16
17
18
19
20
21
22
23
24
# File 'lib/latest_tomatoes_cli_gem/cli.rb', line 16

def new_dvds
  puts "New movies on DVD & Streaming:"
  @movies = LatestTomatoes::Movies.latest

  @movies.each.with_index(1) do |movie, index|
    movie[:tomatoScore] != nil ? tmeter = "#{movie[:tomatoScore]}%\n" : tmeter = "N/A"
    puts "#{index}. #{movie[:title]} - #{tmeter}"  
  end
end

#new_moviesObject



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

def new_movies
 puts "  Lastest DVD and streaming releases with tomato meter ratings.\n  DOC\n  new_dvds\nend\n".gsub /^\s+/, ""