class OpenWeatherMap::CurrentWeather
Represents the current weather at a location
Attributes
city[R]
@return [OpenWeatherMap::City] Requested city's data
weather_conditions[R]
@return [OpenWeatherMap::WeatherConditions] Conditions at the moment
Public Class Methods
new(data)
click to toggle source
Create a new CurrentWeather
object
@param data [Hash] mixed data from the request
# 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