class Showtimes::App

Attributes

theater_choice[RW]
zipcode[RW]

Public Instance Methods

display_showtimes(index) click to toggle source
# File lib/showtimes/app.rb, line 75
def display_showtimes(index)
  selection = Showtimes::Theater.all[index-1]
  stars = "*" * selection.name.length
  
  puts "\n"
  puts "*************************************#{stars}"
  puts "***** Movies playing today at #{selection.name}: *****"
  puts "*************************************#{stars}"
  puts "\n"

  selection.movies.each_with_index do |showtimes, index|
    puts "#{index+1}. #{showtimes[:movie_name]}"
    
    showtimes[:movie_times].each do |time|
      puts "   #{time}"
    end

    puts "\n"
  end
end
display_theaters() click to toggle source
# File lib/showtimes/app.rb, line 56
def display_theaters
  puts "\n"
  puts "These theaters are closest to #{zipcode}:"

  Showtimes::Theater.all.each.with_index do |t, index|
    puts "#{index+1}. #{t.name}"
  end
end
get_zip_code() click to toggle source
# File lib/showtimes/app.rb, line 14
def get_zip_code
  Showtimes::Theater.clear

  puts "What is your zipcode?"
  @zipcode = gets.strip
  
  if @zipcode !~ /\d{5}/
    system('clear') 
    puts "*****************************************************************"
    puts "***** Whoops. Looks like you entered an invalid zipcode. 😩  *****"
    puts "*****************************************************************"
    puts "\n"
    get_zip_code
  end
    
  Showtimes::Scraper.new.scrape_showtimes(zipcode)

  theater_selection
end
theater_selection() click to toggle source
# File lib/showtimes/app.rb, line 65
def theater_selection
  display_theaters    
  puts "\n"
  puts "For which theater do you wish to see the showtimes? (enter the number)"
  theater_choice = gets.strip.to_i
  display_showtimes(theater_choice)
  
  what_next
end
welcome() click to toggle source
# File lib/showtimes/app.rb, line 5
def welcome
  puts "\n"
  puts "**********************************************"
  puts "********** Movie Showtimes Near You **********"
  puts "**********************************************"
  puts "\n"
  get_zip_code
end
what_next() click to toggle source
# File lib/showtimes/app.rb, line 34
def what_next
  puts "\n"
  puts "That's it! What do you want to do next?"
  puts "1: try a new zipcode"
  puts "2: back to theaters"
  puts "3: exit"
  next_up = gets.strip
  if next_up == "1"
    get_zip_code
  elsif next_up == "2"
    theater_selection
  else
    system('clear') 
    puts "\n"
    puts "****************************************************"
    puts "********** BYEEEEEEEEEEE. See you soon! ♥ **********"
    puts "****************************************************"
    puts "\n"
    exit
  end
end