Class: TravelInspiration::CLI
- Inherits:
-
Object
- Object
- TravelInspiration::CLI
- Defined in:
- lib/travel_inspiration/cli.rb
Instance Method Summary collapse
- #country_details(chosen_country) ⇒ Object
- #goodbye ⇒ Object
- #list_destinations(theme_name) ⇒ Object
- #list_themes ⇒ Object
- #select_country(country_arr) ⇒ Object
- #select_theme(theme_arr) ⇒ Object
- #start ⇒ Object
Instance Method Details
#country_details(chosen_country) ⇒ Object
79 80 81 82 |
# File 'lib/travel_inspiration/cli.rb', line 79 def country_details(chosen_country) country = TravelInspiration::Country.new(chosen_country) puts country.country_info end |
#goodbye ⇒ Object
84 85 86 87 |
# File 'lib/travel_inspiration/cli.rb', line 84 def goodbye puts "\nFarewell, traveler! May the wind take you somewhere new!".red.on_white.bold exit end |
#list_destinations(theme_name) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/travel_inspiration/cli.rb', line 45 def list_destinations(theme_name) puts "Please select a destination from 1 - 6".blue.bold country_arr = TravelInspiration::Destination.list_destination_names(theme_name) puts country_arr.map.with_index{|d, index| "\t#{index+1}. #{d.name}, #{d.continent}" } puts "--------------------------------------------".black.on_white #horizontal divider select_country(country_arr) end |
#list_themes ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/travel_inspiration/cli.rb', line 14 def list_themes puts "Hello! Which travel inspiration will you like to explore for your next trip?".green.bold puts "\nPlease select a theme from 1 - 12".blue.bold theme_arr = TravelInspiration::Theme.list_theme_names puts theme_arr.map.with_index{|theme, index| "\t#{index+1}. #{theme.name}" } puts "--------------------------------------------".black.on_white #horizontal divider select_theme(theme_arr) end |
#select_country(country_arr) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/travel_inspiration/cli.rb', line 56 def select_country(country_arr) user_input = nil while true # user_input != "exit" user_input = Readline.readline("Select country 🗺 ", true).strip goodbye if user_input.downcase === "exit" country_choice = user_input.to_i if country_choice > 0 && country_choice < 7 puts "--------------------------------------------".black.on_white #horizontal divider #select country = array[country_choice] chosen_country = country_arr[country_choice-1].name.upcase puts "Here's some information about #{chosen_country}, and the best time to travel there!".green.bold country_details(chosen_country) else puts "That selection is not valid. Please select a country from 1-6, or type exit." end end end |
#select_theme(theme_arr) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/travel_inspiration/cli.rb', line 25 def select_theme(theme_arr) input = nil while true # user_input != "exit" input = Readline.readline("Select theme 🛣 ", true).strip goodbye if input.downcase === "exit" input = input.to_i if input > 0 && input < 13 puts "--------------------------------------------".black.on_white #horizontal divider theme_name = theme_arr[input-1].name.strip puts "Here are the top 6 destinations for #{theme_name.upcase}\n".green.bold list_destinations(theme_name) else puts "That selection is not valid. Please select a theme from 1 - 12, or type exit." end end end |
#start ⇒ Object
10 11 12 |
# File 'lib/travel_inspiration/cli.rb', line 10 def start list_themes end |