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

delete_menu() click to toggle source
# File lib/what_to_watch.rb, line 71
def delete_menu
  system('clear')
end
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_menu() click to toggle source
print_result(results) click to toggle source
print_title(title = 'W H A T T O W A T C H') click to toggle source
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