Class: Everlog::Inf::Cache::File
- Inherits:
-
Everlog::Inf::Cache
- Object
- Everlog::Inf
- Everlog::Inf::Cache
- Everlog::Inf::Cache::File
- Defined in:
- lib/everlog/inf/cache/file.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Wunderground
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #flush ⇒ Object
- #get_and_save(date, proc_args = {}, &api_proc) ⇒ Object
-
#initialize ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize ⇒ File
Returns a new instance of File.
7 8 9 10 |
# File 'lib/everlog/inf/cache/file.rb', line 7 def initialize service = self.class.name.split('::').last.downcase @cache = LocalFileCache.new("#{::File.dirname(__FILE__)}/data/#{service}") end |
Instance Method Details
#delete(key) ⇒ Object
19 20 21 |
# File 'lib/everlog/inf/cache/file.rb', line 19 def delete key @cache.delete key end |
#flush ⇒ Object
23 24 25 |
# File 'lib/everlog/inf/cache/file.rb', line 23 def flush @cache.flush end |
#get_and_save(date, proc_args = {}, &api_proc) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/everlog/inf/cache/file.rb', line 12 def get_and_save(date, proc_args = {}, &api_proc) return @cache.get(date) if @cache.has?(date) data = api_proc.call(proc_args) @cache.set(date, data) data end |