Class: OpenWeatherMap::CurrentWeather

Inherits:
Object
  • Object
show all
Defined in:
lib/openweathermap/current-weather.rb

Overview

Represents the current weather at a location

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CurrentWeather

Create a new CurrentWeather object

Parameters:

  • data (Hash)

    mixed data from the request



13
14
15
16
17
# File 'lib/openweathermap/current-weather.rb', line 13

def initialize(data)
  data = JSON.parse(data)
  @city = OpenWeatherMap::City.new(data['name'], data['coord']['lon'], data['coord']['lat'], data['sys']['country'])
  @weather_conditions = OpenWeatherMap::WeatherConditions.new(data)
end

Instance Attribute Details

#cityOpenWeatherMap::City (readonly)

Returns Requested city’s data.

Returns:



8
9
10
# File 'lib/openweathermap/current-weather.rb', line 8

def city
  @city
end

#weather_conditionsOpenWeatherMap::WeatherConditions (readonly)

Returns Conditions at the moment.

Returns:



5
6
7
# File 'lib/openweathermap/current-weather.rb', line 5

def weather_conditions
  @weather_conditions
end