class Adventures::Adventure

Attributes

description[RW]
elevation_gain[RW]
location[RW]
rt_distance[RW]
season[RW]
skill_level[RW]
suggested_activities[RW]
summary[RW]
title[RW]
trail_type[RW]
url[RW]

Public Class Methods

all() click to toggle source
# File lib/adventures/adventure.rb, line 22
def self.all
        @@all
end
find(id) click to toggle source
# File lib/adventures/adventure.rb, line 26
def self.find(id)
        self.all[id -1]
end
new(title = nil, location = nil, url = nil) click to toggle source
# File lib/adventures/adventure.rb, line 15
def initialize(title = nil, location = nil, url = nil)
        @title = title
        @location = location
        @url = url
        @@all << self
end
new_from_scrape(a) click to toggle source
# 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

Public Instance Methods

doc() click to toggle source
# File lib/adventures/adventure.rb, line 30
def doc
        @doc ||= Nokogiri::HTML(open(self.url))
end