Class: WeatherSage::Weather::Period

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

Overview

Numerical weather forecast period.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ctx, data) ⇒ Period

Create new forecast period from given data.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/weather-sage/weather/period.rb', line 22

def initialize(ctx, data)
  @ctx = ctx
  @data = data.freeze

  # log data
  @ctx.log.debug('Period#initialize') do
    'data = %p' % [data]
  end

  @name = data['name']
  @start_time = Time.parse(data['startTime'])
  @end_time = Time.parse(data['endTime'])
  @is_daytime = data['isDaytime']
  @temperature = data['temperature']
  @temperature_unit = data['temperatureUnit']
  @temperature_trend = data['temperatureTrend']
  @wind_speed = data['windSpeed']
  @wind_direction = data['windDirection']
  @icon = data['icon']
  @short_forecast = data['shortForecast']
  @detailed_forecast = data['detailedForecast']
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def data
  @data
end

#detailed_forecastObject (readonly)

Returns the value of attribute detailed_forecast.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def detailed_forecast
  @detailed_forecast
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def end_time
  @end_time
end

#iconObject (readonly)

Returns the value of attribute icon.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def icon
  @icon
end

#is_daytimeObject (readonly)

Returns the value of attribute is_daytime.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def is_daytime
  @is_daytime
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def name
  @name
end

#short_forecastObject (readonly)

Returns the value of attribute short_forecast.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def short_forecast
  @short_forecast
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def start_time
  @start_time
end

#temperatureObject (readonly)

Returns the value of attribute temperature.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def temperature
  @temperature
end

#temperature_trendObject (readonly)

Returns the value of attribute temperature_trend.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def temperature_trend
  @temperature_trend
end

#temperature_unitObject (readonly)

Returns the value of attribute temperature_unit.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def temperature_unit
  @temperature_unit
end

#wind_directionObject (readonly)

Returns the value of attribute wind_direction.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def wind_direction
  @wind_direction
end

#wind_speedObject (readonly)

Returns the value of attribute wind_speed.



5
6
7
# File 'lib/weather-sage/weather/period.rb', line 5

def wind_speed
  @wind_speed
end