class OpenWeatherMap::WeatherConditions

Represents the weather conditions

Attributes

clouds[R]

@return [Float] Clouds percentage

description[R]

@return [String] Details of weather conditions

emoji[R]

@return [String] Conditions illustrated by an emoji

humidity[R]

@return [Float] Humidity percentage

icon[R]

@return [String] URL to conditions icon illustration

main[R]

@return [String] Main weather conditions at the moment

pressure[R]

@return [Float] Atmospheric pressure in hPa

rain[R]

@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

snow[R]

@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

temp_max[R]

@return [Float] Maximum temperature at the moment (for large areas)

temp_min[R]

@return [Float] Minimum temperature at the moment (for large areas)

temperature[R]

@return [Float] Temperature

time[R]

@return [Time] time of the condition

wind[R]

@return [Hash] Wind data. Keys : (symbols)

- speed : Wind speed (m/s or miles/hour)
- direction : Wind direction (meteorological degrees)

Public Class Methods

new(data) click to toggle source

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