class Snowfall::Report

Attributes

state[RW]
url[RW]

Public Class Methods

new(state) click to toggle source
# File lib/snowfall/report.rb, line 9
def initialize state
  self.state = state
  self.url   = format_url state
end

Public Instance Methods

resorts() click to toggle source
# File lib/snowfall/report.rb, line 14
def resorts
  Nokogiri::HTML(open(url)).xpath('//rss/channel/item').map do |i|
    OpenStruct.new({
      name:       i.xpath('title').text,
      updated:    i.xpath('pubdate').text,
      status:     i.xpath('open_staus').text,
      conditions: i.xpath('surface_condition').text,

      base: {
        depth:    i.xpath('base_depth').text,
        metric:   i.xpath('base_depth_metric').text
      },

      snowfall: {
        amount:   i.xpath('snowfall_48hr').text,
        metric:   i.xpath('snowfall_48hr_metric').text
      }
    })
  end
end

Private Instance Methods

format_url(state) click to toggle source
# File lib/snowfall/report.rb, line 37
def format_url state
  "http://www.onthesnow.com/#{state.downcase.strip.gsub(' ', '-')}/snow-rss.html"
end