Class: FileCache
Constant Summary collapse
- MAXDURATION =
60 * 10
Instance Attribute Summary collapse
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
Class Method Summary collapse
Instance Method Summary collapse
- #cache! ⇒ Object
-
#initialize(filepath) ⇒ FileCache
constructor
A new instance of FileCache.
Constructor Details
#initialize(filepath) ⇒ FileCache
12 13 14 |
# File 'lib/file_cache.rb', line 12 def initialize(filepath) @filepath = filepath end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
11 12 13 |
# File 'lib/file_cache.rb', line 11 def filepath @filepath end |
Class Method Details
.get(filepath, &blk) ⇒ Object
7 8 9 |
# File 'lib/file_cache.rb', line 7 def self.get(filepath, &blk) new(filepath).cache!(&blk) end |
Instance Method Details
#cache! ⇒ Object
16 17 18 19 20 |
# File 'lib/file_cache.rb', line 16 def cache! return read_cache if cached? yield.tap { write_cache(_1) } end |