class Barometer::Noaa::Response::CurrentWeather
Attributes
current[R]
payload[R]
Public Class Methods
new(payload)
click to toggle source
# File lib/barometer/noaa/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/noaa/response/current_weather.rb, line 10 def parse current.observed_at = observed_at, '%a, %d %b %Y %H:%M:%S %z' current.stale_at = stale_at current.humidity = humidity current.condition = condition current.icon = icon current.temperature = temperature current.dew_point = dew_point current.wind_chill = wind_chill current.wind = wind current.pressure = pressure current.visibility = visibility current end
Private Instance Methods
condition()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 46 def condition payload.fetch('weather') end
dew_point()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 58 def dew_point [units, payload.fetch('dewpoint_c'), payload.fetch('dewpoint_f')] end
humidity()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 42 def humidity payload.fetch('relative_humidity') end
icon()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 50 def icon payload.using(/(.*).(jpg|png)$/).fetch('icon_url_name') end
observed_at()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 34 def observed_at payload.fetch('observation_time_rfc822') end
pressure()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 70 def pressure [units, payload.fetch('pressure_mb'), payload.fetch('pressure_in')] end
stale_at()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 38 def stale_at current.observed_at + (60 * 60 * 1) if current.observed_at end
temperature()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 54 def temperature [units, payload.fetch('temp_c'), payload.fetch('temp_f')] end
units()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 30 def units payload.units end
visibility()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 74 def visibility [:imperial, payload.fetch('visibility_mi').to_f] end
wind()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 66 def wind [:imperial, payload.fetch('wind_mph').to_f, payload.fetch('wind_degrees').to_i] end
wind_chill()
click to toggle source
# File lib/barometer/noaa/response/current_weather.rb, line 62 def wind_chill [units, payload.fetch('windchill_c'), payload.fetch('windchill_f')] end