class Destinations::TravelDestinations
Attributes
link_url[RW]
list_number[RW]
name[RW]
summary[RW]
Public Class Methods
all()
click to toggle source
# File lib/destinations/travel_destinations_info.rb, line 53 def self.all @@all end
find_input_to_index(input, more_input)
click to toggle source
# File lib/destinations/travel_destinations_info.rb, line 64 def self.find_input_to_index(input, more_input) if input.to_i == 1 self.all[more_input.to_i-1] elsif input.to_i == 2 self.all[10 + more_input.to_i-1] elsif input.to_i == 3 self.all[20 + more_input.to_i-1] elsif input.to_i == 4 self.all[30 + more_input.to_i-1] end end
new_cities()
click to toggle source
# File lib/destinations/travel_destinations_info.rb, line 20 def self.new_cities Destinations::TravelDestinationsLists.scrape_cities.each do |city| new_city = self.new new_city.name = city.css(".marketing-article__header h1").text.scan(/[a-zA-Z]+.*/).join new_city.link_url = city.css("a").attribute("href").text new_city.list_number = city.css(".marketing-article__header h1").text.scan(/\d+/).join.to_i new_city.summary = city.css("p.marketing-article__content").text self.all << new_city end end
new_countries()
click to toggle source
# File lib/destinations/travel_destinations_info.rb, line 9 def self.new_countries Destinations::TravelDestinationsLists.scrape_countries.each do |country| new_country = self.new new_country.name = country.css(".marketing-article__header h1").text.scan(/[a-zA-Z]+.*/).join new_country.link_url = country.css("a").attribute("href").text new_country.list_number = country.css(".marketing-article__header h1").text.scan(/\d+/).join.to_i new_country.summary = country.css("p.marketing-article__content").text self.all << new_country end end
new_regions()
click to toggle source
# File lib/destinations/travel_destinations_info.rb, line 31 def self.new_regions Destinations::TravelDestinationsLists.scrape_regions.each do |region| new_region = self.new new_region.name = region.css(".marketing-article__header h1").text.scan(/[a-zA-Z]+.*/).join new_region.link_url = region.css("a").attribute("href").text new_region.list_number = region.css(".marketing-article__header h1").text.scan(/\d+/).join.to_i new_region.summary = region.css("p.marketing-article__content").text self.all << new_region end end
new_value()
click to toggle source
# File lib/destinations/travel_destinations_info.rb, line 42 def self.new_value Destinations::TravelDestinationsLists.scrape_value.each do |value| new_value = self.new new_value.name = value.css(".marketing-article__header h1").text.scan(/[a-zA-Z]+.*/).join new_value.link_url = value.css("a").attribute("href").text new_value.list_number = value.css(".marketing-article__header h1").text.scan(/\d+/).join.to_i new_value.summary = value.css("p.marketing-article__content").text self.all << new_value end end
put_all()
click to toggle source
# File lib/destinations/travel_destinations_info.rb, line 57 def self.put_all self.all.each_with_index do |destination, index| puts "#{index+1}. #{destination.name}" end end