Class: Forecast::IO::Cache::Generate

Inherits:
Object
  • Object
show all
Defined in:
lib/forecast_io/cache/generate.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lat, lon, time, cache, api = ::Forecast::IO) ⇒ Generate

Returns a new instance of Generate.



12
13
14
# File 'lib/forecast_io/cache/generate.rb', line 12

def initialize lat, lon, time, cache, api = ::Forecast::IO
  @lat, @lon, @time, @cache, @api = lat, lon, time, cache, api
end

Class Method Details

.for(lat, lon, time, cache) ⇒ Object



8
9
10
# File 'lib/forecast_io/cache/generate.rb', line 8

def self.for lat, lon, time, cache
  new(lat, lon, time, cache).forecasts.first
end

Instance Method Details

#forecastsObject



16
17
18
19
20
# File 'lib/forecast_io/cache/generate.rb', line 16

def forecasts
  ([current] + hourly).map do |forecast|
    @cache.store generate forecast
  end
end