Class: OpenWeatherMap::Forecast

Inherits:
Object
  • Object
show all
Defined in:
lib/openweathermap/forecast.rb

Overview

Represents the forecast for a specific location

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Forecast

Create a new Forecast object

Parameters:

  • data (Hash)

    mixed data from the request



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

#cityOpenWeatherMap::City (readonly)

Returns Requested city’s data.

Returns:



5
6
7
# File 'lib/openweathermap/forecast.rb', line 5

def city
  @city
end

#forecastArray<OpenWeatherMap::WeatherConditions> (readonly)

Returns Forecast for many days and hours.

Returns:



8
9
10
# File 'lib/openweathermap/forecast.rb', line 8

def forecast
  @forecast
end