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



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)



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

def city
  @city
end

#forecast ⇒ Array<OpenWeatherMap::WeatherConditions> (readonly)



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

def forecast
  @forecast
end