class GeekWeather::Forecast::Day
Public Class Methods
new(json)
click to toggle source
{
"date": { "epoch": "1487268000", "pretty": "7:00 PM CET on February 16, 2017", "day": 16, "month": 2, "year": 2017, "yday": 46, "hour": 19, "min": "00", "sec": 0, "isdst": "0", "monthname": "February", "monthname_short": "Feb", "weekday_short": "Thu", "weekday": "Thursday", "ampm": "PM", "tz_short": "CET", "tz_long": "Europe/Berlin" }, "period": 1, "high": { "fahrenheit": "59", "celsius": "15" }, "low": { "fahrenheit": "39", "celsius": "4" }, "conditions": "Rain", "icon": "rain", "icon_url": "http://icons.wxug.com/i/c/k/rain.gif", "skyicon": "", "pop": 90, "qpf_allday": { "in": 0.09, "mm": 2 }, "qpf_day": { "in": null, "mm": null }, "qpf_night": { "in": 0.13, "mm": 3 }, "snow_allday": { "in": 0.0, "cm": 0.0 }, "snow_day": { "in": null, "cm": null }, "snow_night": { "in": 0.0, "cm": 0.0 }, "maxwind": { "mph": 9, "kph": 15, "dir": "NNW", "degrees": 0 }, "avewind": { "mph": 3, "kph": 5, "dir": "South", "degrees": 0 }, "avehumidity": 94, "maxhumidity": 0, "minhumidity": 0
},
# File lib/geek_weather/forecast/day.rb, line 79 def initialize(json) @json = json end
Public Instance Methods
date()
click to toggle source
# File lib/geek_weather/forecast/day.rb, line 83 def date # binding.pry @date ||= begin day = @json["date"]["day"] month = @json["date"]["month"] year = @json["date"]["year"] Date.parse("#{day}/#{month}/#{year}") end end
high(scale = "celsius")
click to toggle source
# File lib/geek_weather/forecast/day.rb, line 93 def high(scale = "celsius") @json["high"][scale] end
icon_url()
click to toggle source
docs: www.wunderground.com/weather/api/d/docs?d=resources/icon-sets
# File lib/geek_weather/forecast/day.rb, line 106 def icon_url icon = @json["icon"] icon_set = "i" "https://icons.wxug.com/i/c/#{icon_set}/#{icon}.gif" end
low(scale = "celsius")
click to toggle source
# File lib/geek_weather/forecast/day.rb, line 97 def low(scale = "celsius") @json["low"][scale] end
maxwind(scale = "kph")
click to toggle source
# File lib/geek_weather/forecast/day.rb, line 101 def maxwind(scale = "kph") @json["maxwind"][scale] end
to_s()
click to toggle source
# File lib/geek_weather/forecast/day.rb, line 112 def to_s <<~EOS #{date} max: #{high} C min: #{low} C wind: #{maxwind} km/h EOS end