Class: OpenWeatherMap::CurrentWeather
- Inherits:
-
Object
- Object
- OpenWeatherMap::CurrentWeather
- Defined in:
- lib/openweathermap/current-weather.rb
Overview
Represents the current weather at a location
Instance Attribute Summary collapse
-
#city ⇒ OpenWeatherMap::City
readonly
Requested city’s data.
-
#weather_conditions ⇒ OpenWeatherMap::WeatherConditions
readonly
Conditions at the moment.
Instance Method Summary collapse
-
#initialize(data) ⇒ CurrentWeather
constructor
Create a new CurrentWeather object.
Constructor Details
#initialize(data) ⇒ CurrentWeather
Create a new CurrentWeather object
25 26 27 28 29 30 31 32 33 |
# File 'lib/openweathermap/current-weather.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['name'], data['coord']['lon'], data['coord']['lat'], data['sys']['country']) @weather_conditions = OpenWeatherMap::WeatherConditions.new(data) end |
Instance Attribute Details
#city ⇒ OpenWeatherMap::City (readonly)
Returns Requested city’s data.
18 19 20 |
# File 'lib/openweathermap/current-weather.rb', line 18 def city @city end |
#weather_conditions ⇒ OpenWeatherMap::WeatherConditions (readonly)
Returns Conditions at the moment.
13 14 15 |
# File 'lib/openweathermap/current-weather.rb', line 13 def weather_conditions @weather_conditions end |