class OpenWeatherMap::Forecast
Represents the forecast for a specific location
Attributes
city[R]
@return [OpenWeatherMap::City] Requested city's data
forecast[R]
@return [Array<OpenWeatherMap::WeatherConditions>] Forecast
for many days and hours
Public Class Methods
new(data)
click to toggle source
Create a new Forecast
object
@param data [Hash] mixed data from the request
# File lib/openweathermap/forecast.rb, line 25 def initialize(data) begin data = JSON.parse(data) rescue JSON::JSONError => e raise OpenWeatherMap::Exceptions::DataError, "error while parsing data : #{e}" end @city = OpenWeatherMap::City.new(data['city']['name'], data['city']['coord']['lon'], data['city']['coord']['lat'], data['city']['country']) @forecast = [] data['list'].each do |element| forecast << OpenWeatherMap::WeatherConditions.new(element) end end