Class: Tenkit::Weather

Inherits:
Object
  • Object
show all
Defined in:
lib/tenkit/weather.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Weather

Returns a new instance of Weather.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tenkit/weather.rb', line 15

def initialize(response)
  parsed_response = JSON.parse(response.body)

  current_weather = parsed_response['currentWeather']
  forecast_daily = parsed_response['forecastDaily']
  forecast_hourly = parsed_response['forecastHourly']
  forecast_next_hour = parsed_response['forecastNextHour']
  weather_alerts = parsed_response['weatherAlerts']

  @current_weather = CurrentWeather.new(current_weather)
  @forecast_daily = DailyForecast.new(forecast_daily)
  @forecast_hourly = HourlyForecast.new(forecast_hourly)
  @forecast_next_hour = NextHourForecast.new(forecast_next_hour)
  @weather_alerts = WeatherAlertCollection.new(weather_alerts)
end

Instance Attribute Details

#current_weatherObject (readonly)

Returns the value of attribute current_weather.



9
10
11
# File 'lib/tenkit/weather.rb', line 9

def current_weather
  @current_weather
end

#forecast_dailyObject (readonly)

Returns the value of attribute forecast_daily.



9
10
11
# File 'lib/tenkit/weather.rb', line 9

def forecast_daily
  @forecast_daily
end

#forecast_hourlyObject (readonly)

Returns the value of attribute forecast_hourly.



9
10
11
# File 'lib/tenkit/weather.rb', line 9

def forecast_hourly
  @forecast_hourly
end

#forecast_next_hourObject (readonly)

Returns the value of attribute forecast_next_hour.



9
10
11
# File 'lib/tenkit/weather.rb', line 9

def forecast_next_hour
  @forecast_next_hour
end

#weather_alertsObject (readonly)

Returns the value of attribute weather_alerts.



9
10
11
# File 'lib/tenkit/weather.rb', line 9

def weather_alerts
  @weather_alerts
end