Class: Barometer::WeatherService::WundergroundV1::Response::ForecastedWeather

Inherits:
Object
  • Object
show all
Defined in:
lib/barometer/weather_services/wunderground_v1/response/forecasted_weather.rb

Instance Method Summary collapse

Constructor Details

#initialize(payload, response) ⇒ ForecastedWeather

Returns a new instance of ForecastedWeather.



6
7
8
9
10
# File 'lib/barometer/weather_services/wunderground_v1/response/forecasted_weather.rb', line 6

def initialize(payload, response)
  @payload = payload
  @response = response
  @predictions = Barometer::Response::PredictionCollection.new
end

Instance Method Details

#parseObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/barometer/weather_services/wunderground_v1/response/forecasted_weather.rb', line 12

def parse
  each_prediction do |prediction, forecast_payload|
    prediction.starts_at = starts_at(forecast_payload), '%I:%M %p %Z on %B %d, %Y'
    prediction.ends_at = ends_at(prediction.starts_at)
    prediction.pop = pop(forecast_payload)
    prediction.icon = icon(forecast_payload)
    prediction.high = high(forecast_payload)
    prediction.low = low(forecast_payload)
    prediction.sun = sun(prediction.starts_at, prediction.ends_at)
  end

  predictions
end