class Forecast::IO::Cache::Generate
Public Class Methods
for(lat, lon, time, cache)
click to toggle source
# File lib/forecast_io/cache/generate.rb, line 8 def self.for lat, lon, time, cache new(lat, lon, time, cache).forecasts.first end
new(lat, lon, time, cache, api = ::ForecastIO)
click to toggle source
# File lib/forecast_io/cache/generate.rb, line 12 def initialize lat, lon, time, cache, api = ::ForecastIO @lat, @lon, @time, @cache, @api = lat, lon, time, cache, api end
Public Instance Methods
forecasts()
click to toggle source
# File lib/forecast_io/cache/generate.rb, line 16 def forecasts ([current] + hourly).map do |forecast| @cache.store generate forecast end end
Private Instance Methods
current()
click to toggle source
# File lib/forecast_io/cache/generate.rb, line 23 def current forecast["currently"] end
forecast()
click to toggle source
# File lib/forecast_io/cache/generate.rb, line 31 def forecast @forecast ||= @api.forecast @lat, @lon, time: @time end
generate(data)
click to toggle source
# File lib/forecast_io/cache/generate.rb, line 35 def generate data ForecastData.generate @lat, @lon, data end
hourly()
click to toggle source
# File lib/forecast_io/cache/generate.rb, line 27 def hourly forecast["hourly"]["data"] end