Class: WeatherSage::Weather::Forecast

Inherits:
Object
  • Object
show all
Defined in:
lib/weather-sage/weather/forecast.rb

Overview

Numerical weather forecast.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/weather-sage/weather/forecast.rb', line 7

def data
  @data
end

#elevationObject (readonly)

Returns the value of attribute elevation.



7
8
9
# File 'lib/weather-sage/weather/forecast.rb', line 7

def elevation
  @elevation
end

#generated_atObject (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

#generatorObject (readonly)

Returns the value of attribute generator.



7
8
9
# File 'lib/weather-sage/weather/forecast.rb', line 7

def generator
  @generator
end

#periodsObject (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

#unitsObject (readonly)

Returns the value of attribute units.



7
8
9
# File 'lib/weather-sage/weather/forecast.rb', line 7

def units
  @units
end

#update_timeObject (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_atObject (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_timesObject (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