Class: ComingSoon::CLI
- Inherits:
-
Object
- Object
- ComingSoon::CLI
- Defined in:
- lib/coming_soon/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #get_and_list_movies ⇒ Object
- #goodbye ⇒ Object
- #list_saved_movies ⇒ Object
- #menu_selection ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/coming_soon/cli.rb', line 3 def call puts '' puts ' **************************' puts ' | Movies Coming Soon |' puts ' | -------------- |' puts ' | Please wait! |' puts ' **************************' puts '' ComingSoon::Scraper.new.scrape_movies get_and_list_movies end |
#get_and_list_movies ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/coming_soon/cli.rb', line 19 def get_and_list_movies ComingSoon::Movie.movies.each.with_index(1) do |movie, i| # set the first index to 1 and use the index number for the movie number if i < 10 spacer = ' ' else spacer = '' end puts "#{spacer}#{i}. #{movie.name} - #{movie.start_date}" end end |
#goodbye ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/coming_soon/cli.rb', line 71 def goodbye puts '' puts ' ***************************' puts ' | Thank you and goodbye |' puts ' | ----------------- |' puts ' | Come back soon! |' puts ' ***************************' puts '' exit end |
#list_saved_movies ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/coming_soon/cli.rb', line 32 def list_saved_movies puts '' puts ' **************************' puts ' | Movies Coming Soon |' puts ' **************************' puts '' ComingSoon::Movie.movies.each.with_index(1) do |movie, i| # set the first index to 1 and use the index number for the movie number puts "#{i}. #{movie.name} - #{movie.start_date}" end end |
#menu_selection ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/coming_soon/cli.rb', line 46 def input = '' while input != 'exit' puts '' puts 'You may enter a movie number for more details or "list" to see the menu again or "exit"' input = gets.strip.downcase if input.to_i > 0 && input.to_i < ComingSoon::Movie.movies.size+1 puts "* #{ComingSoon::Movie.movies[input.to_i - 1].name} - #{ComingSoon::Movie.movies[input.to_i - 1].start_date} *" puts ComingSoon::Movie.movies[input.to_i - 1].synopsis elsif input == 'list' list_saved_movies elsif input == 'exit' goodbye else puts 'Invalid selection!' end end end |