class Forecast::IO::Cache::Forecast

Public Class Methods

new(cache = Store.new, generate = Generate) click to toggle source
# File lib/forecast_io/cache/forecast.rb, line 6
def initialize cache = Store.new, generate = Generate
  @cache, @generate = cache, generate
end

Public Instance Methods

for(lat, lon, time) click to toggle source
# File lib/forecast_io/cache/forecast.rb, line 10
def for lat, lon, time
  cached(lat, lon, time) or fetch_and_store(lat, lon, time)
end

Private Instance Methods

cached(lat, lon, time) click to toggle source
# File lib/forecast_io/cache/forecast.rb, line 15
def cached lat, lon, time
  @cache.fetch lat, lon, time
end
fetch_and_store(lat, lon, time) click to toggle source
# File lib/forecast_io/cache/forecast.rb, line 19
def fetch_and_store lat, lon, time
  @generate.for lat, lon, time, @cache
end