class TripAdvisorBest::CLI
Attributes
sites[R]
Public Class Methods
new()
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 4 def initialize @sites = [ {class_name: TripAdvisorBest::Museum, url: "https://www.tripadvisor.com/TravelersChoice-Museums#1"}, {class_name: TripAdvisorBest::Attraction, url: "https://www.tripadvisor.com/TravelersChoice-Attractions"}, {class_name: TripAdvisorBest::Landmark, url: "https://www.tripadvisor.com/TravelersChoice-Landmarks"} ] make_highlights end
Public Instance Methods
add_highlight_details(highlight)
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 112 def add_highlight_details(highlight) attributes = TripAdvisorBest::Scraper.new.scrap_details_page(highlight.url) highlight.add_highlight_attributes(attributes) end
call()
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 22 def call welcome menu end
goodbye()
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 117 def goodbye puts "Bon voyage!" end
highlight_details(class_name, highlight)
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 99 def highlight_details(class_name, highlight) puts"#{highlight.ranking}. - #{highlight.name} - #{highlight.location}".colorize(:yellow) puts " #{highlight.description}".colorize(:light_blue) puts "----------------------".colorize(:green) puts "Would you like to see another? (y or n)" input = gets.strip.downcase if input == "y" list_highlight_details(class_name) end end
list_highlight_details(class_name)
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 83 def list_highlight_details(class_name) puts "Which would you like to see in greater detail?" input = gets.strip.to_i if input.between?(1, 25) highlight = class_name.find(input - 1) add_highlight_details(highlight) highlight_details(class_name, highlight) else puts "I didn't get that..." list_highlight_details(class_name) end end
list_hightlights(class_name)
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 77 def list_hightlights(class_name) class_name.all.each do |highlight| puts "#{highlight.ranking}. - #{highlight.name}".colorize(:yellow) end end
list_options()
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 65 def list_options puts "Currently you can see..." puts "" puts <<-DOC 1. Top 25 Museums 2. Top 25 Attractions 3. Top 25 Landmarks DOC puts "" puts "Which would you like to see?" end
make_highlights()
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 13 def make_highlights puts "Planning your next big trip..." self.sites.each do |site| highlights_array = [] highlights_array = TripAdvisorBest::Scraper.new.scrape_listings_page(site[:url]) site[:class_name].create_from_collection(highlights_array) end end
welcome()
click to toggle source
# File lib/tripadvisor_best/cli.rb, line 27 def welcome puts "" puts "The TripAdvisor Traveler's Choice Awards are out.".colorize(:red) puts "" puts "Are you ready to travel the world?" puts " (Type 'exit' to leave program.)" puts "" end