class WhatToWatch
Constants
- VERSION
Public Class Methods
new(api_key)
click to toggle source
# File lib/what_to_watch.rb, line 8 def initialize(api_key) @controller = WhatToWatchController.new(api_key) end
Public Instance Methods
evaluate_input(input_text)
click to toggle source
# File lib/what_to_watch.rb, line 36 def evaluate_input(input_text) delete_menu case input_text when 'Q' exit when /^what'*s on the theaters$/ results = @controller.on_theaters print_title("What's on theaters") when /^trailer .*/ input_text.gsub!('trailer', '') results = @controller.trailer(input_text) print_title("Trailer #{input_text}") when /^coming soon$/ results = @controller.coming_soon print_title('Coming soon movies') when /[0-9a-zA-Z\s]/ results = @controller.recommend(input_text) print_title("Recommendations") else results = 'Invalid command.' end print_result(results) end
print_result(results)
click to toggle source
# File lib/what_to_watch.rb, line 60 def print_result(results) if results.is_a?(String) puts(results) else results.each do |result| puts(result['title']) end end puts end
print_title(title = 'W H A T T O W A T C H')
click to toggle source
# File lib/what_to_watch.rb, line 30 def print_title(title = 'W H A T T O W A T C H') puts puts(" #{title}") puts end
start(title = true)
click to toggle source
# File lib/what_to_watch.rb, line 12 def start(title = true) print_title if title print_menu evaluate_input(gets.chomp) start(false) end