class NewYorkFilms::CLI

Public Instance Methods

call() click to toggle source
# File lib/new_york_films/cli.rb, line 5
def call
  prompt
end
choose_theater(input) click to toggle source
# File lib/new_york_films/cli.rb, line 67
def choose_theater(input)
  NewYorkFilms::FilmFinder.scraper
  NewYorkFilms::FilmFinder.all.each do |film|
    if film.theater == input
      puts "\n" + "THEATER: #{film.theater}\n" + "FILM: #{film.title}\n" + "DIRECTOR: #{film.director}\n" + "YEAR: #{film.year} - LENGTH: #{film.length}\n" + "TIMES: #{film.times}\n" + "MORE INFO: #{film.website}\n" + "LOCATION: #{film.location}"
    end
  end
  what_next?
end
hard_out() click to toggle source
# File lib/new_york_films/cli.rb, line 91
def hard_out
  puts "\n"+"'No art passes our conscience in the way film does, and goes directly to our feelings, deep down into the dark rooms of our souls.'\n   -Ingmar Bergman"
  exit
end
prompt(input=nil) click to toggle source
# File lib/new_york_films/cli.rb, line 10
def prompt(input=nil)
  if input == nil
      puts "\n" + "Welcome to today's listing for arthouse film screenings in NYC. \nWould you like to see 1. All or 2. Listings by theater?"
      input = gets.chomp
      case input
      when "1", "all", "1."
        show_all
      when "2", "by theater", "2."
        theater_select
      when "exit"
       hard_out
      else
        puts "Please type 1 or 2 to see listings."
        prompt
      end
  elsif input == "1"
    show_all
  elsif input == "2"
    theater_select
  end
end
show_all() click to toggle source
# File lib/new_york_films/cli.rb, line 32
def show_all
  puts "Give me just one minute to get those for you..."
  NewYorkFilms::FilmFinder.scraper
  x = NewYorkFilms::FilmFinder.all
  x.each do |film|
    puts "\n" + "THEATER: #{film.theater}\n" + "FILM: #{film.title}\n" + "DIRECTOR: #{film.director}\n" + "YEAR: #{film.year} - LENGTH: #{film.length}\n" + "TIMES: #{film.times}\n" + "MORE INFO: #{film.website}\n" + "LOCATION: #{film.location}"
  end
  what_next?
end
theater_select() click to toggle source
# File lib/new_york_films/cli.rb, line 43
def theater_select
  puts "Enter the number of the theater you'd like to see:"
  NewYorkFilms::FilmFinder.theater_scraper
  x = NewYorkFilms::FilmFinder.theaters.uniq
  x.each.with_index(1) do |film,index|
   puts "#{index}. #{film}"
  end
  answer = gets.chomp
  puts "Give me just one minute to get that for you..."


 theater_choice = "#{x.at(answer.to_i - 1)}"
    if answer.to_i.between?(1,x.length+1)
       choose_theater(theater_choice)
    elsif answer == "exit"
      hard_out
    else
      puts "Please enter a correct number."
      prompt("2")
    end
end
what_next?() click to toggle source
# File lib/new_york_films/cli.rb, line 77
def what_next?
  puts "\n"+"Would you like to 1. Go back to main menu or 2. Exit?"
  input = gets.chomp.downcase
  case input
  when "1", "menu", "1."
    prompt
  when "2", "2.", "exit"
    hard_out
  else
    puts "Not sure what you meant. Please enter 1 to go to the menu or 2 to exit."
    what_next?
  end
end