class OpenWeatherMap::WeatherConditions
Represents the weather conditions
Attributes
@return [Float] Clouds percentage
@return [String] Details of weather conditions
@return [String] Conditions illustrated by an emoji
@return [Float] Humidity percentage
@return [String] URL to conditions icon illustration
@return [String] Main weather conditions at the moment
@return [Float] Atmospheric pressure in hPa
@return [Hash, nil] Rain volume. Keys : (symbols)
- one_hour : Rain volume for the last 1 hour (mm) - three_hours : Rain volume for the last 3 hours (mm)
Can be nil if there is no rain
@return [Hash, nil] Snow volume. Keys : (symbols)
- one_hour : Snow volume for the last 1 hour (mm) - three_hours : Snow volume for the last 3 hours (mm)
Can be nil if there is no snow
@return [Float] Maximum temperature at the moment (for large areas)
@return [Float] Minimum temperature at the moment (for large areas)
@return [Float] Temperature
@return [Time] time of the condition
@return [Hash] Wind data. Keys : (symbols)
- speed : Wind speed (m/s or miles/hour) - direction : Wind direction (meteorological degrees)
Public Class Methods
Create a new WeatherConditions
object.
@param data [Hash] all the received data
# File lib/openweathermap/classes.rb, line 155 def initialize(data) @time = Time.at(data['dt']) @main = data['weather'][0]['main'] @description = data['weather'][0]['description'] @icon = "https://openweathermap.org/img/w/#{data['weather'][0]['icon']}.png" @emoji = OpenWeatherMap::Constants::CONDITION_CODE[data['weather'][0]['icon'].tr('n', 'd')] @temperature = data['main']['temp'] @temp_min = data['main']['temp_min'].to_f @temp_max = data['main']['temp_max'].to_f @pressure = data['main']['pressure'].to_f @humidity = data['main']['humidity'].to_f @wind = { speed: data['wind']['speed'], direction: data['wind']['deg'] } @clouds = data['clouds']['all'].to_f @rain = data['rain'].nil? ? nil : { one_hour: data['rain']['1h'], three_hours: data['rain']['3h'] } @snow = data['snow'].nil? ? nil : { one_hour: data['snow']['1h'], three_hours: data['snow']['3h'] } end