Class: Horror::Movie::Cli

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

Instance Method Summary collapse

Instance Method Details

#another_movie?Boolean

Returns:

  • (Boolean)


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/horror/movie/cli.rb', line 85

def another_movie?
  input = gets.strip.downcase
  until input == "yes" || input == "no" || input == "exit"
    puts ""
    puts "------------------------------------------------".colorize :red
    puts "Invalid answer.".colorize :red
    puts ""
     input = gets.strip.downcase
  end
  if input == "yes"
    main_program
  elsif input == "no" || input == "exit"
    goodbye
  end
end

#correct_number?Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/horror/movie/cli.rb', line 49

def correct_number?
  input = gets.strip
  until input.downcase == "no" || (1..25).include?(input.to_i) || input.downcase == "exit"
    puts ""
    puts "------------------------------------------------".colorize :red
    puts "Invalid answer.".colorize :red
    puts ""
    input = gets.strip
  end
  if (1..25).include? input.to_i
    movie = Horror::Movie::Listing.find(input.to_i)
    print_movie(movie)
    return movie
  elsif input.downcase == "no" || input.downcase == "exit"
    goodbye
  end
end

#goodbyeObject



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/horror/movie/cli.rb', line 136

def goodbye
 puts ""
 puts "------------------------------------------------".colorize :red
 puts "Thank you for your interest. Have a spooky day!".colorize :red
 puts ""
 puts ""
puts File.read("lib/horror/movie/skull.txt").colorize :red
puts ""
puts "------------------------------------------------".colorize :red
 exit
end

#main_programObject



17
18
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
47
# File 'lib/horror/movie/cli.rb', line 17

def main_program

    print_movies

    puts "------------------------------------------------".colorize :red
    puts ""
  puts "Would you like further information on a movie?".colorize :red
    puts ""
    puts "------------------------------------------------".colorize :red
  puts "If yes, please enter a number 1-25.".colorize :red
  puts "If not, please enter no.".colorize :red
  puts ""

  movie = correct_number?

  puts "------------------------------------------------".colorize :red
  puts "Would you like to see the movie's summary and a random review?".colorize :red
  puts ""
  puts "Please enter yes or no.".colorize :red
  puts ""

  summary_and_review?(movie)

  puts ""
  puts "Would you like to see information on another movie?".colorize :red
  puts ""
  puts "Please enter yes or no.".colorize :red
  puts ""

  another_movie?
end


101
102
103
104
105
106
107
108
109
110
111
# File 'lib/horror/movie/cli.rb', line 101

def print_movie(movie)
  puts ""
puts "---------------- Movie Stats ---------------".colorize :red
puts ""
puts "Rank:                    #{movie.rank}"
puts "Rating:                  #{movie.rating}"
puts "Movie Title:             #{movie.movie_title}"
puts "Movie Url:               #{movie.movie_url}"
puts "Number of Reviews:       #{movie.number_of_reviews}"
puts ""
end


113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/horror/movie/cli.rb', line 113

def print_movie_info(movie)
  movie_info = movie.movie_info
puts ""                     
  puts "---------------- Movie Synopsis ---------------".colorize :red
puts ""
puts "#{movie_info.movie_synopsis}"
puts ""
puts "---------------- Random Review ----------------".colorize :red
puts ""
puts "#{movie_info.movie_review}"
puts ""
puts "------------------------------------------------".colorize :red
end


127
128
129
130
131
132
133
134
# File 'lib/horror/movie/cli.rb', line 127

def print_movies
puts ""
puts "---------- Rotten Tomatoes: Top 25 Horror Movies ----------".colorize :red
puts ""
Horror::Movie::Listing.all.each.with_index do |movie, index|
   puts "#{index + 1}. #{movie.movie_title}"
 end
end

#summary_and_review?(movie) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/horror/movie/cli.rb', line 68

def summary_and_review?(movie)
  input = gets.strip.downcase
  until input == "yes" || input == "no" || input == "exit"
    puts ""
    puts "------------------------------------------------".colorize :red
    puts "Invalid answer.".colorize :red
    puts ""
     input = gets.strip.downcase
  end
  if input == "yes"
    print_movie_info(movie)
  elsif input == "no"
  elsif input == "exit"
    goodbye
  end
end

#welcomeObject



8
9
10
11
12
13
14
15
# File 'lib/horror/movie/cli.rb', line 8

def welcome
  Horror::Movie::Scraper.new.scrape_horror_movies
  puts File.read("lib/horror/movie/intro.txt").colorize :red
  puts ""
  puts "Hello! Welcome to the Rotten Tomatoes: Top 25 Horror Movies List.".colorize :red
  puts ""
  main_program
end