Class: NOAA::Forecast
- Inherits:
-
Object
- Object
- NOAA::Forecast
- Defined in:
- lib/noaa/forecast.rb
Overview
A Forecast object represents a multi-day forecast for a particular place. The forecast for a given day can be accessed using the [] method; e.g. (assuming forecast
is a forecast for 12/20/2008 - 12/24/2008):
forecast[1] #=> ForecastDay for 12/21/2008
forecast.length #=> 4
Class Method Summary collapse
-
.from_xml(doc) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#[](i) ⇒ Object
Get the ForecastDay for day i.
-
#initialize(doc) ⇒ Forecast
constructor
:noinit:.
-
#length ⇒ Object
The number of days provided by the forecast.
Constructor Details
#initialize(doc) ⇒ Forecast
:noinit:
19 20 21 |
# File 'lib/noaa/forecast.rb', line 19 def initialize(doc) #:noinit: @doc = doc end |
Class Method Details
.from_xml(doc) ⇒ Object
:nodoc:
14 15 16 |
# File 'lib/noaa/forecast.rb', line 14 def from_xml(doc) #:nodoc: new(doc) end |
Instance Method Details
#[](i) ⇒ Object
Get the ForecastDay for day i
forecast[1] #=> returns the ForecastDay for the second day
35 36 37 |
# File 'lib/noaa/forecast.rb', line 35 def [](i) forecast_days[i] end |
#length ⇒ Object
The number of days provided by the forecast
26 27 28 |
# File 'lib/noaa/forecast.rb', line 26 def length @length ||= @doc.find(%q{/dwml/data/time-layout[@summarization='24hourly'][1]/start-valid-time}).length end |