Class: Destinations::CLI
- Inherits:
-
Object
- Object
- Destinations::CLI
- Defined in:
- lib/destinations/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #destination_link(destination) ⇒ Object
- #destination_more_info(input) ⇒ Object
- #exit_or_menu(new_answer) ⇒ Object
- #intro ⇒ Object
- #main_menu ⇒ Object
- #main_menu_select ⇒ Object
Instance Method Details
#call ⇒ Object
4 5 6 7 |
# File 'lib/destinations/cli.rb', line 4 def call intro end |
#destination_link(destination) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/destinations/cli.rb', line 64 def destination_link(destination) answer = gets.chomp.downcase if answer == 'more info' puts "\nPlease visit #{destination.link_url} for more information on #{destination.name}.\n\n" puts "To exit the program, enter 'exit'. To return to the main menu, enter 'main menu'." new_input = gets.chomp.downcase self.(new_input) else self.(answer) end end |
#destination_more_info(input) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/destinations/cli.rb', line 45 def destination_more_info(input) more_input = gets.chomp.downcase destination = nil if more_input.to_i.between?(1,10) destination = Destinations::TravelDestinations.find_input_to_index(input, more_input) puts destination.summary puts "If you would like more information about this destination please enter 'more info'." self.destination_link(destination) elsif more_input.to_i.between?(11,40) destination = Destinations::TravelDestinations.all[more_input.to_i-1] puts destination.summary puts "If you would like more information about this destination please enter 'more info'." self.destination_link(destination) else self.(more_input) end end |
#exit_or_menu(new_answer) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/destinations/cli.rb', line 76 def (new_answer) if new_answer == "main menu" self. elsif new_answer == "exit" abort("Bye!") else puts "To exit the program, enter 'exit'. To return to the main menu, enter 'main menu'." more_answer = gets.chomp.downcase self.(more_answer) end end |
#intro ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/destinations/cli.rb', line 9 def intro Destinations::TravelDestinationsLists.scrape_list Destinations::TravelDestinations.new_countries Destinations::TravelDestinations.new_cities Destinations::TravelDestinations.new_regions Destinations::TravelDestinations.new_value puts "\nWelcome! Please select one of the lists above by number.\n\n" puts "Type 'exit' to exit the program at anytime. Type 'main menu' to return to the list above at anytime." end |
#main_menu ⇒ Object
19 20 21 22 23 |
# File 'lib/destinations/cli.rb', line 19 def Destinations::TravelDestinationsLists.scrape_list puts "\nPlease select a list." self. end |
#main_menu_select ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/destinations/cli.rb', line 25 def input = gets.chomp list = nil if input.to_i == 1 Destinations::TravelDestinationsLists.puts_countries elsif input.to_i == 2 Destinations::TravelDestinationsLists.puts_cities elsif input.to_i == 3 Destinations::TravelDestinationsLists.puts_regions elsif input.to_i == 4 Destinations::TravelDestinationsLists.puts_value elsif input.to_i == 5 Destinations::TravelDestinations.put_all else self.(input) end puts "\nIf you would like to read about one of these destinations, please enter it's number on the list.\n\n" self.destination_more_info(input) end |