Class: NewYorkFilms::CLI

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

Instance Method Summary collapse

Instance Method Details

#callObject



5
6
7
# File 'lib/new_york_films/cli.rb', line 5

def call
  prompt
end

#choose_theater(input) ⇒ Object



67
68
69
70
71
72
73
74
75
# 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_outObject



91
92
93
94
# 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) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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_allObject



32
33
34
35
36
37
38
39
40
# 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_selectObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 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?Boolean

Returns:

  • (Boolean)


77
78
79
80
81
82
83
84
85
86
87
88
89
# 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