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
- #clear! ⇒ Object
-
#initialize(filepath) ⇒ FileCache
constructor
A new instance of FileCache.
Constructor Details
#initialize(filepath) ⇒ FileCache
23 24 25 |
# File 'lib/file_cache.rb', line 23 def initialize(filepath) @filepath = filepath end |
Instance Attribute Details
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
22 23 24 |
# File 'lib/file_cache.rb', line 22 def filepath @filepath end |
Class Method Details
.clear(filepath) ⇒ Object
12 13 14 |
# File 'lib/file_cache.rb', line 12 def self.clear(filepath) new(filepath).clear! end |
.clear_all ⇒ Object
16 17 18 19 20 |
# File 'lib/file_cache.rb', line 16 def self.clear_all File.join(Dir.tmpdir, "dcm-*.dump") .then { Dir.glob(_1) } .each { FileUtils.rm(_1) } end |
.get(filepath, &blk) ⇒ Object
8 9 10 |
# File 'lib/file_cache.rb', line 8 def self.get(filepath, &blk) new(filepath).cache!(&blk) end |