class Barometer::Yahoo::Response::CurrentWeather
Attributes
current[R]
payload[R]
timezone[R]
Public Class Methods
new(payload, timezone)
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 8 def initialize(payload, timezone) @payload = payload @timezone = timezone @current = Barometer::Response::Current.new # needs query or metric end
Public Instance Methods
parse()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 14 def parse current.observed_at = observed_at, '%a, %d %b %Y %l:%M %P %Z' current.stale_at = stale_at current.condition = condition current.icon = icon current.temperature = temperature current.humidity = humidity current.pressure = pressure current.visibility = visibility current.wind_chill = wind_chill current.wind = wind current.sun = Yahoo::Response::Sun.new(payload, base_time).parse current end
Private Instance Methods
base_time()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 38 def base_time OpenStruct.new(timezone: timezone, base: current.observed_at) end
condition()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 50 def condition payload.fetch('item', 'condition', '@text') end
humidity()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 62 def humidity payload.fetch('atmosphere', '@humidity') end
icon()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 54 def icon payload.fetch('item', 'condition', '@code') end
observed_at()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 42 def observed_at payload.fetch('item', 'pubDate') end
pressure()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 66 def pressure [units, payload.fetch('atmosphere', '@pressure')] end
stale_at()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 46 def stale_at (current.observed_at + (60 * 60 * 1)) if current.observed_at end
temperature()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 58 def temperature [units, payload.fetch('item', 'condition', '@temp')] end
units()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 34 def units payload.units end
visibility()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 70 def visibility [units, payload.fetch('atmosphere', '@visibility')] end
wind()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 78 def wind [units, payload.fetch('wind', '@speed'), payload.fetch('wind', '@direction').to_f] end
wind_chill()
click to toggle source
# File lib/barometer/yahoo/response/current_weather.rb, line 74 def wind_chill [units, payload.fetch('wind', '@chill')] end