Class: Adventures::Adventure

Inherits:
Object
  • Object
show all
Defined in:
lib/adventures/adventure.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def description
  @description
end

#elevation_gainObject

Returns the value of attribute elevation_gain.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def elevation_gain
  @elevation_gain
end

#locationObject

Returns the value of attribute location.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def location
  @location
end

#rt_distanceObject

Returns the value of attribute rt_distance.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def rt_distance
  @rt_distance
end

#seasonObject

Returns the value of attribute season.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def season
  @season
end

#skill_levelObject

Returns the value of attribute skill_level.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def skill_level
  @skill_level
end

#suggested_activitiesObject

Returns the value of attribute suggested_activities.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def suggested_activities
  @suggested_activities
end

#summaryObject

Returns the value of attribute summary.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def summary
  @summary
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def title
  @title
end

#trail_typeObject

Returns the value of attribute trail_type.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def trail_type
  @trail_type
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/adventures/adventure.rb', line 3

def url
  @url
end

Class Method Details

.allObject



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

#docObject



30
31
32
# File 'lib/adventures/adventure.rb', line 30

def doc
  @doc ||= Nokogiri::HTML(open(self.url))
end