class NewMovies::CLI

Constants

WIDTH

Public Instance Methods

call() click to toggle source
# File lib/new_movies/CLI.rb, line 18
def call
  NewMovies::Scraper.scrape_coming_soon_movies
  main_menu
end
center(string, c = "-") click to toggle source
# File lib/new_movies/CLI.rb, line 5
def center(string, c = "-")
   string = " #{string} " if string != ""
   until string.length >= WIDTH
     string.prepend(c)
     string << (c)
   end
   string.prepend("\n")
 end
goodbye() click to toggle source
# File lib/new_movies/CLI.rb, line 85
def goodbye
  puts "See you next time!"
  exit
end
list_new_movies() click to toggle source
# File lib/new_movies/CLI.rb, line 23
def list_new_movies
  puts center("MOVIES COMING SOON TO CINEMARK THEATRES")
  puts " "
  NewMovies::Movie.all.each_with_index do |movie, index|
    puts "    #{index+1}. #{movie.title}" if index.to_i+1 < 10
    puts "   #{index+1}. #{movie.title}" if index.to_i+1 >= 10
  end
    puts center("END OF LIST")
    puts " "
end
main_menu() click to toggle source
menu() click to toggle source
menu_restart() click to toggle source
movie_details(input) click to toggle source
# File lib/new_movies/CLI.rb, line 69
def movie_details(input)
  details = NewMovies::Movie.find_movie_by_index(input)
  puts center("#{details.title.upcase}")
  puts " "
  puts "  URL: #{details.url}" if details.url
  puts "  Runtime: #{details.runtime}" if details.runtime
  puts "  Rating: #{details.rating}" if details.rating != ""
  puts "  Genre: #{details.genre}" if details.genre
  puts "  Release Date: #{details.release_date}" if details.release_date
  puts "  Director: #{details.director}" if details.director
  puts wrap("  Cast: #{details.cast}") if details.cast
  puts wrap("\n  Synopsis: #{details.synopsis}") if details.synopsis
  puts "  Movie Site: #{details.movie_site}" if details.movie_site
  puts center("END OF DETAILS")
end
wrap(s) click to toggle source
# File lib/new_movies/CLI.rb, line 14
def wrap(s)
     s.gsub(/(.{1,#{WIDTH}})(\s+|\Z)/, "\\1\n  ")
   end