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.
6 7 8 9 |
# File 'lib/everlog/inf/cache/file.rb', line 6 def initialize service = self.class.name.split('::').last.downcase @cache = LocalFileCache.new("#{::File.dirname(__FILE__)}/data/#{service}") end |
Instance Method Details
#delete(key) ⇒ Object
18 19 20 |
# File 'lib/everlog/inf/cache/file.rb', line 18 def delete key @cache.delete key end |
#flush ⇒ Object
22 23 24 |
# File 'lib/everlog/inf/cache/file.rb', line 22 def flush @cache.flush end |
#get_and_save(date, proc_args = {}, &api_proc) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/everlog/inf/cache/file.rb', line 11 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 |