class LocalSkiReport::Resort
Attributes
lifts[RW]
location[RW]
name[RW]
reports[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/local_ski_report/resort.rb, line 20 def self.all @@all end
clear()
click to toggle source
# File lib/local_ski_report/resort.rb, line 24 def self.clear @@all.clear end
create(html)
click to toggle source
# File lib/local_ski_report/resort.rb, line 28 def self.create(html) name = html.css('td div.name').text url = html.css('div.name a').first['href'] location = html.css('td div.rRegion').text lifts = html.css('td')[4].text.split("/").last self.new(name, url, location, lifts) end
find_by_location(location)
click to toggle source
# File lib/local_ski_report/resort.rb, line 36 def self.find_by_location(location) self.all.find_all { |resort| resort.location == location } end
new(name, url, location, lifts)
click to toggle source
# File lib/local_ski_report/resort.rb, line 6 def initialize(name, url, location, lifts) @reports = [] @name = name @url = url @location = location @lifts = lifts @@all << self end
sort_by_lifts_desc()
click to toggle source
# File lib/local_ski_report/resort.rb, line 40 def self.sort_by_lifts_desc self.all.sort { |x, y| y.lifts.to_i <=> x.lifts.to_i } end
Public Instance Methods
add_report(report)
click to toggle source
# File lib/local_ski_report/resort.rb, line 15 def add_report(report) report.resort = self self.reports << report end