Class: Barometer::WeatherBug::Response::ForecastedWeather

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

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ ForecastedWeather

Returns a new instance of ForecastedWeather.



5
6
7
8
# File 'lib/barometer/weather_bug/response/forecasted_weather.rb', line 5

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

Instance Method Details

#parseObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/barometer/weather_bug/response/forecasted_weather.rb', line 10

def parse
  each_prediction do |prediction, forecast_payload, index|
    prediction.starts_at = starts_at(forecast_payload)
    prediction.ends_at = ends_at(prediction.starts_at)
    prediction.condition = condition(forecast_payload)
    prediction.icon = icon(forecast_payload)
    prediction.pop = pop(forecast_payload)

    if is_day?(forecast_payload)
      prediction.high = high(forecast_payload)
    else
      prediction.low = low(forecast_payload)
    end
  end

  predictions
end