class Barometer::WeatherBug::Response::CurrentWeather

Attributes

current[R]
payload[R]

Public Class Methods

new(payload) click to toggle source
# File lib/barometer/weather_bug/response/current_weather.rb, line 5
def initialize(payload)
  @payload = payload
  @current = Barometer::Response::Current.new
end

Public Instance Methods

parse() click to toggle source
# File lib/barometer/weather_bug/response/current_weather.rb, line 10
def parse
  current.observed_at = observed_at
  current.humidity = humidity
  current.icon = icon
  current.temperature = temperature
  current.dew_point = dew_point
  current.wind = wind

  current
end

Private Instance Methods

dew_point() click to toggle source
# File lib/barometer/weather_bug/response/current_weather.rb, line 45
def dew_point
  [units, payload.fetch('dewPoint')]
end
humidity() click to toggle source
# File lib/barometer/weather_bug/response/current_weather.rb, line 33
def humidity
  payload.fetch('humidity')
end
icon() click to toggle source
# File lib/barometer/weather_bug/response/current_weather.rb, line 37
def icon
  payload.fetch('iconCode')
end
observed_at() click to toggle source
# File lib/barometer/weather_bug/response/current_weather.rb, line 29
def observed_at
  Utils::Time.parse(payload.fetch('observationTimeUtcStr'), '%Y-%m-%dT%H:%M:%S')
end
temperature() click to toggle source
# File lib/barometer/weather_bug/response/current_weather.rb, line 41
def temperature
  [units, payload.fetch('temperature')]
end
units() click to toggle source
# File lib/barometer/weather_bug/response/current_weather.rb, line 25
def units
  payload.units
end
wind() click to toggle source
# File lib/barometer/weather_bug/response/current_weather.rb, line 49
def wind
  [units, payload.fetch('windSpeed'), payload.fetch('windDirection')]
end