class MoviesAroundYou::CLI
Attributes
movie[R]
url[R]
zip_code[R]
Public Instance Methods
add_movie_to_theater()
click to toggle source
# File lib/movies_around_you/cli.rb, line 21 def add_movie_to_theater movie_array = MoviesAroundYou::Scraper.new.movies_scraper(url) movie_array.each do |array| new_array = array.collect{|hash| MoviesAroundYou::Movie.new(hash)} MoviesAroundYou::Theater.all[movie_array.index(array)].add_movie_from_collection(new_array) end end
call()
click to toggle source
# File lib/movies_around_you/cli.rb, line 87 def call puts "<<<<=================================>>>>" puts "<< >>" puts "<< MOVIES >>" puts "<< Around >>" puts "<< You!! >>" puts "<< >>" puts "<<<<=================================>>>>" get_zip zip_to_url make_theater add_movie_to_theater theaters_around movies end
continue_or_exit()
click to toggle source
# File lib/movies_around_you/cli.rb, line 71 def continue_or_exit puts "Choose another theater? (Y/n)" input = gets.strip.downcase case input when "y" theaters_around movies when "n" puts "<<<<=================================>>>>" puts " Goodbye! Enjoy your movie!! " puts "<<<<=================================>>>>" end end
get_zip()
click to toggle source
# File lib/movies_around_you/cli.rb, line 5 def get_zip puts "Please enter your zip code to start" @zip_code=gets.strip end
make_theater()
click to toggle source
# File lib/movies_around_you/cli.rb, line 14 def make_theater theater_array = MoviesAroundYou::Scraper.new.theater_scraper(url) theater_array.each do |theater_name| MoviesAroundYou::Theater.new(theater_name) end end
movies()
click to toggle source
# File lib/movies_around_you/cli.rb, line 40 def movies puts "Which one are you going?" theater_number = gets.to_i puts "=============================================================" puts "These are the movies playing today" MoviesAroundYou::Theater.all[theater_number-1].movies.each_with_index do |movie, index| if movie.genre puts "#{index+1}. #{movie.title} (#{movie.genre})" else puts "#{index+1}. #{movie.title}" end end puts "=============================================================" puts "Pick a movie" movie_number = gets.to_i @movie = MoviesAroundYou::Theater.all[theater_number-1].movies[movie_number-1] puts "=============================================================" puts "<<<<<#{movie.title}>>>>>" if movie.time_available != [] puts "Showtimes available:" movie.time_available.each{|time| puts "#{time}"} else puts "Tickets are all out for today" end puts "=============================================================" continue_or_exit end
theaters_around()
click to toggle source
# File lib/movies_around_you/cli.rb, line 29 def theaters_around puts "=============================================================" puts "Here are the theaters around you:" theaters_array = MoviesAroundYou::Theater.all theaters_array.each_with_index do |theater, index| puts "#{index+1}. #{theater.name}" end puts "=============================================================" end
zip_to_url()
click to toggle source
# File lib/movies_around_you/cli.rb, line 10 def zip_to_url @url = "http://www.fandango.com/#{zip_code}_movietimes?q=#{zip_code}" end