Class: OpenWeatherMap::Forecast
- Inherits:
-
Object
- Object
- OpenWeatherMap::Forecast
- Defined in:
- lib/openweathermap/forecast.rb
Overview
Represents the forecast for a specific location
Instance Attribute Summary collapse
-
#city ⇒ OpenWeatherMap::City
readonly
Requested city’s data.
-
#forecast ⇒ Array<OpenWeatherMap::WeatherConditions>
readonly
Forecast for many days and hours.
Instance Method Summary collapse
-
#initialize(data) ⇒ Forecast
constructor
Create a new Forecast object.
Constructor Details
#initialize(data) ⇒ Forecast
Create a new Forecast object
13 14 15 16 17 18 19 20 |
# File 'lib/openweathermap/forecast.rb', line 13 def initialize(data) data = JSON.parse(data) @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 |
Instance Attribute Details
#city ⇒ OpenWeatherMap::City (readonly)
Returns Requested city’s data.
5 6 7 |
# File 'lib/openweathermap/forecast.rb', line 5 def city @city end |
#forecast ⇒ Array<OpenWeatherMap::WeatherConditions> (readonly)
Returns Forecast for many days and hours.
8 9 10 |
# File 'lib/openweathermap/forecast.rb', line 8 def forecast @forecast end |