Class: Barometer::Noaa::Response::ForecastedWeather

Inherits:
Object
  • Object
show all
Defined in:
lib/barometer/noaa/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/noaa/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
# File 'lib/barometer/noaa/response/forecasted_weather.rb', line 10

def parse
  each_prediction do |prediction, index, shared_index|
    prediction.starts_at = start_times[index]
    prediction.ends_at = end_times[index]
    prediction.icon = icons[shared_index]
    prediction.condition = summaries[shared_index]
    prediction.pop = precipitations[index]
    prediction.high = [:imperial, high_temperatures[shared_index]]
    prediction.low = [:imperial, low_temperatures[shared_index]]
  end

  predictions
end