Class: WeatherSage::Weather::Forecast
- Inherits:
-
Object
- Object
- WeatherSage::Weather::Forecast
- Defined in:
- lib/weather-sage/weather/forecast.rb
Overview
Numerical weather forecast.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#elevation ⇒ Object
readonly
Returns the value of attribute elevation.
-
#generated_at ⇒ Object
readonly
Returns the value of attribute generated_at.
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
-
#periods ⇒ Object
readonly
Return an array of periods for this forecast.
-
#units ⇒ Object
readonly
Returns the value of attribute units.
-
#update_time ⇒ Object
readonly
Returns the value of attribute update_time.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#valid_times ⇒ Object
readonly
Returns the value of attribute valid_times.
Instance Method Summary collapse
-
#initialize(ctx, data) ⇒ Forecast
constructor
Create new forecast object from given data.
Constructor Details
#initialize(ctx, data) ⇒ Forecast
Create new forecast object from given data.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/weather-sage/weather/forecast.rb', line 20 def initialize(ctx, data) # cache context and data, get properties @ctx, @data = ctx, data.freeze props = @data['properties'] # log data @ctx.log.debug('Forecast#initialize') do 'data = %p' % [@data] end @updated_at = Time.parse(props['updated']) @units = props['units'] @generator = props['generator'] @generated_at = Time.parse(props['generatedAt']) @update_time = Time.parse(props['updateTime']) @valid_times = props['validTimes'] @elevation = props['elevation']['value'] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/weather-sage/weather/forecast.rb', line 7 def data @data end |
#elevation ⇒ Object (readonly)
Returns the value of attribute elevation.
7 8 9 |
# File 'lib/weather-sage/weather/forecast.rb', line 7 def elevation @elevation end |
#generated_at ⇒ Object (readonly)
Returns the value of attribute generated_at.
7 8 9 |
# File 'lib/weather-sage/weather/forecast.rb', line 7 def generated_at @generated_at end |
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
7 8 9 |
# File 'lib/weather-sage/weather/forecast.rb', line 7 def generator @generator end |
#periods ⇒ Object (readonly)
Return an array of periods for this forecast.
42 43 44 |
# File 'lib/weather-sage/weather/forecast.rb', line 42 def periods @periods end |
#units ⇒ Object (readonly)
Returns the value of attribute units.
7 8 9 |
# File 'lib/weather-sage/weather/forecast.rb', line 7 def units @units end |
#update_time ⇒ Object (readonly)
Returns the value of attribute update_time.
7 8 9 |
# File 'lib/weather-sage/weather/forecast.rb', line 7 def update_time @update_time end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
7 8 9 |
# File 'lib/weather-sage/weather/forecast.rb', line 7 def updated_at @updated_at end |
#valid_times ⇒ Object (readonly)
Returns the value of attribute valid_times.
7 8 9 |
# File 'lib/weather-sage/weather/forecast.rb', line 7 def valid_times @valid_times end |