class OpenWeather::Weather

Attributes

date[R]
humidity[R]
icon[R]
speed[R]
temp[R]
temp_max[R]
temp_min[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/weather.rb, line 5
def initialize(options = {})
  main = options['main']
  @speed    = options['wind']['speed']
  @humidity = main['humidity']
  @temp     = to_fahrenheit(main['temp'])
  @temp_min = to_fahrenheit(main['temp_min'])
  @temp_max = to_fahrenheit(main['temp_max'])
  @icon     = options['weather'][0]['main']
  @date     = options['dt_txt'] || Time.now
end

Private Instance Methods

to_fahrenheit(x) click to toggle source
# File lib/weather.rb, line 18
def to_fahrenheit(x)
  { kelvin: x, fahrenheit: x * (9 / 5.0) - 459.67 }
end