class Barometer::ForecastIo::Response::CurrentWeather
Attributes
current[R]
payload[R]
Public Class Methods
new(payload)
click to toggle source
# File lib/barometer/forecast_io/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/forecast_io/response/current_weather.rb, line 10 def parse current.observed_at = observed_at current.humidity = humidity current.condition = condition current.icon = icon current.temperature = temperature current.dew_point = dew_point current.wind = wind current.pressure = pressure current.visibility = visibility current end
Private Instance Methods
condition()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 40 def condition payload.fetch('currently', 'summary') end
convert_metre_per_second(value)
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 70 def convert_metre_per_second(value) value.to_f * 60 * 60 / 1000 end
dew_point()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 52 def dew_point [units, payload.fetch('currently', 'dewPoint')] end
humidity()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 36 def humidity payload.fetch('currently', 'humidity') * 100 end
icon()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 44 def icon payload.fetch('currently', 'icon') end
observed_at()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 32 def observed_at Time.at(payload.fetch('currently', 'time').to_i) end
pressure()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 60 def pressure [:metric, payload.fetch('currently', 'pressure')] end
temperature()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 48 def temperature [units, payload.fetch('currently', 'temperature')] end
units()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 28 def units payload.units end
visibility()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 64 def visibility [units, payload.fetch('currently', 'visibility')] end
wind()
click to toggle source
# File lib/barometer/forecast_io/response/current_weather.rb, line 56 def wind [units, convert_metre_per_second(payload.fetch('currently', 'windSpeed')), payload.fetch('currently', 'windBearing').to_i] end