Class: TravelLeisure::Destination
- Inherits:
-
Object
- Object
- TravelLeisure::Destination
- Defined in:
- lib/travel_leisure/destination.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#best_time_to_visit ⇒ Object
Returns the value of attribute best_time_to_visit.
-
#city ⇒ Object
Returns the value of attribute city.
-
#country ⇒ Object
Returns the value of attribute country.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#know_before_visiting ⇒ Object
Returns the value of attribute know_before_visiting.
-
#language ⇒ Object
Returns the value of attribute language.
-
#transportation ⇒ Object
Returns the value of attribute transportation.
-
#url ⇒ Object
Returns the value of attribute url.
-
#weather ⇒ Object
Returns the value of attribute weather.
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(city = nil, country = nil, url = nil) ⇒ Destination
constructor
A new instance of Destination.
- #save ⇒ Object
Constructor Details
#initialize(city = nil, country = nil, url = nil) ⇒ Destination
Returns a new instance of Destination.
13 14 15 16 17 18 |
# File 'lib/travel_leisure/destination.rb', line 13 def initialize(city=nil,country=nil,url=nil) @city = city @country = country @url = url save end |
Instance Attribute Details
#best_time_to_visit ⇒ Object
Returns the value of attribute best_time_to_visit.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def best_time_to_visit @best_time_to_visit end |
#city ⇒ Object
Returns the value of attribute city.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def city @city end |
#country ⇒ Object
Returns the value of attribute country.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def country @country end |
#currency ⇒ Object
Returns the value of attribute currency.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def description @description end |
#know_before_visiting ⇒ Object
Returns the value of attribute know_before_visiting.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def know_before_visiting @know_before_visiting end |
#language ⇒ Object
Returns the value of attribute language.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def language @language end |
#transportation ⇒ Object
Returns the value of attribute transportation.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def transportation @transportation end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def url @url end |
#weather ⇒ Object
Returns the value of attribute weather.
3 4 5 |
# File 'lib/travel_leisure/destination.rb', line 3 def weather @weather end |
Class Method Details
.all ⇒ Object
20 21 22 |
# File 'lib/travel_leisure/destination.rb', line 20 def self.all @@all end |
.find(index) ⇒ Object
28 29 30 |
# File 'lib/travel_leisure/destination.rb', line 28 def self.find(index) self.all[index-1] end |
.new_from_website(r) ⇒ Object
5 6 7 8 9 10 11 |
# 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 |
Instance Method Details
#doc ⇒ Object
32 33 34 |
# File 'lib/travel_leisure/destination.rb', line 32 def doc @doc ||= Nokogiri::HTML(open(self.url)) end |
#save ⇒ Object
24 25 26 |
# File 'lib/travel_leisure/destination.rb', line 24 def save @@all << self end |