Class: Snowfall::Report
- Inherits:
-
Object
- Object
- Snowfall::Report
- Defined in:
- lib/snowfall/report.rb
Instance Attribute Summary collapse
-
#state ⇒ Object
Returns the value of attribute state.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(state) ⇒ Report
constructor
A new instance of Report.
- #resorts ⇒ Object
Constructor Details
#initialize(state) ⇒ Report
Returns a new instance of Report.
9 10 11 12 |
# File 'lib/snowfall/report.rb', line 9 def initialize state self.state = state self.url = format_url state end |
Instance Attribute Details
#state ⇒ Object
Returns the value of attribute state.
7 8 9 |
# File 'lib/snowfall/report.rb', line 7 def state @state end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/snowfall/report.rb', line 7 def url @url end |
Instance Method Details
#resorts ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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 |