class WorldTraveler::CLI
Public Instance Methods
call()
click to toggle source
# File lib/world_traveler/cli.rb, line 3 def call system("clear") WorldTraveler::Display.welcome_message sleep(2) @input = "" while @input != "exit" get_continents list_continents get_user_choice next_action end goodbye end
get_continents()
click to toggle source
# File lib/world_traveler/cli.rb, line 19 def get_continents @continent = WorldTraveler::Continents.all end
get_user_choice()
click to toggle source
# File lib/world_traveler/cli.rb, line 35 def get_user_choice chosen_continent = gets.strip.to_i show_highlights_for(chosen_continent) end
get_user_highlight(cont)
click to toggle source
# File lib/world_traveler/cli.rb, line 55 def get_user_highlight(cont) puts "\nChoose a highlight in #{cont.name} to see more details.".light_blue.bold input = (gets.strip.to_i) if input.between?(1,cont.highlights.size) highlight = cont.highlights[input-1] # highlight.index = input.to_i-1 highlight.get_highlight_details show_highlight_details(highlight) else puts "Not sure what you mean. You must enter a number between 1 - #{cont.highlights.size}." get_user_highlight(cont) end end
goodbye()
click to toggle source
# File lib/world_traveler/cli.rb, line 81 def goodbye system("clear") WorldTraveler::Display.goodbye end
list_continents()
click to toggle source
# File lib/world_traveler/cli.rb, line 23 def list_continents # system("clear") WorldTraveler::Display.continent_list @continent.each.with_index(1) do |continent, index| puts "#{index}. #{continent.name}".center(150).rjust(10) puts "-----------------------------------------".green.center(165) end puts "" puts "Where would you like to go? (Choose 1-#{@continent.size})".center(152).green.bold end
next_action()
click to toggle source
# File lib/world_traveler/cli.rb, line 75 def next_action puts "\nType 'exit' to exit or any key to return to main menu.".green.bold @input = gets.strip system("clear") end
show_highlight_details(highlight)
click to toggle source
# File lib/world_traveler/cli.rb, line 69 def show_highlight_details(highlight) puts "#{highlight.name}".center(170,"-").bold highlight.info.each {|i| puts "\n#{i}\n"} puts "-".center(170, "-").bold end
show_highlights_for(chosen_continent)
click to toggle source
# File lib/world_traveler/cli.rb, line 40 def show_highlights_for(chosen_continent) system("clear") if chosen_continent.between?(1,@continent.size) cont = @continent[chosen_continent - 1] cont.get_highlights puts "Here are highlights in #{cont.name}".light_blue.bold cont.highlights.each.with_index(1) do |high, idx| puts "#{idx}. #{high.name}" end get_user_highlight(cont) else puts "Not sure what you mean. You must enter a number between 1 - #{@continent.size}." end end