class TravelLeisure::Destination

Attributes

best_time_to_visit[RW]
city[RW]
country[RW]
currency[RW]
description[RW]
know_before_visiting[RW]
language[RW]
transportation[RW]
url[RW]
weather[RW]

Public Class Methods

all() click to toggle source
# File lib/travel_leisure/destination.rb, line 20
def self.all
  @@all
end
find(index) click to toggle source
# File lib/travel_leisure/destination.rb, line 28
def self.find(index)
  self.all[index-1]
end
new(city=nil,country=nil,url=nil) click to toggle source
# File lib/travel_leisure/destination.rb, line 13
def initialize(city=nil,country=nil,url=nil)
  @city = city
  @country = country
  @url = url
  save
end
new_from_website(r) click to toggle source
# File lib/travel_leisure/destination.rb, line 5
def self.new_from_website(r)
  self.new(
    r.css("span.grid__item__title").text,
    r.css("span.grid__item__cat").text,
    r.css("a").attribute("href")
  )
end

Public Instance Methods

doc() click to toggle source
# File lib/travel_leisure/destination.rb, line 32
def doc
  @doc ||= Nokogiri::HTML(open(self.url))
end
save() click to toggle source
# File lib/travel_leisure/destination.rb, line 24
def save
  @@all << self
end