Class: Adventures::Adventure
- Inherits:
-
Object
- Object
- Adventures::Adventure
- Defined in:
- lib/adventures/adventure.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#elevation_gain ⇒ Object
Returns the value of attribute elevation_gain.
-
#location ⇒ Object
Returns the value of attribute location.
-
#rt_distance ⇒ Object
Returns the value of attribute rt_distance.
-
#season ⇒ Object
Returns the value of attribute season.
-
#skill_level ⇒ Object
Returns the value of attribute skill_level.
-
#suggested_activities ⇒ Object
Returns the value of attribute suggested_activities.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#title ⇒ Object
Returns the value of attribute title.
-
#trail_type ⇒ Object
Returns the value of attribute trail_type.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(title = nil, location = nil, url = nil) ⇒ Adventure
constructor
A new instance of Adventure.
Constructor Details
#initialize(title = nil, location = nil, url = nil) ⇒ Adventure
Returns a new instance of Adventure.
15 16 17 18 19 20 |
# File 'lib/adventures/adventure.rb', line 15 def initialize(title = nil, location = nil, url = nil) @title = title @location = location @url = url @@all << self end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def description @description end |
#elevation_gain ⇒ Object
Returns the value of attribute elevation_gain.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def elevation_gain @elevation_gain end |
#location ⇒ Object
Returns the value of attribute location.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def location @location end |
#rt_distance ⇒ Object
Returns the value of attribute rt_distance.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def rt_distance @rt_distance end |
#season ⇒ Object
Returns the value of attribute season.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def season @season end |
#skill_level ⇒ Object
Returns the value of attribute skill_level.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def skill_level @skill_level end |
#suggested_activities ⇒ Object
Returns the value of attribute suggested_activities.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def suggested_activities @suggested_activities end |
#summary ⇒ Object
Returns the value of attribute summary.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def summary @summary end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def title @title end |
#trail_type ⇒ Object
Returns the value of attribute trail_type.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def trail_type @trail_type end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/adventures/adventure.rb', line 3 def url @url end |
Class Method Details
.all ⇒ Object
22 23 24 |
# File 'lib/adventures/adventure.rb', line 22 def self.all @@all end |
.find(id) ⇒ Object
26 27 28 |
# File 'lib/adventures/adventure.rb', line 26 def self.find(id) self.all[id -1] end |
.new_from_scrape(a) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/adventures/adventure.rb', line 7 def self.new_from_scrape(a) self.new( a.css("div.info h3.title").text, a.css("div.info p.location").text.strip, "https://www.theoutbound.com/#{a.css("a").attribute("href").text}" ) end |
Instance Method Details
#doc ⇒ Object
30 31 32 |
# File 'lib/adventures/adventure.rb', line 30 def doc @doc ||= Nokogiri::HTML(open(self.url)) end |