Class: Barometer::WeatherService::Yahoo::Response::ForecastedWeather

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

Instance Method Summary collapse

Constructor Details

#initialize(payload, timezone, current_sun) ⇒ ForecastedWeather

Returns a new instance of ForecastedWeather.



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

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

Instance Method Details

#parseObject



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

def parse
  each_prediction do |prediction, forecast_payload|
    prediction.date = date(forecast_payload), timezone
    prediction.icon = icon(forecast_payload)
    prediction.condition = condition(forecast_payload)
    prediction.high = high(forecast_payload)
    prediction.low = low(forecast_payload)
    prediction.sun = sun(forecast_payload, prediction.starts_at, prediction.ends_at)
  end

  predictions
end