Class: Command::Cacheable::CacheFile
- Inherits:
-
Object
- Object
- Command::Cacheable::CacheFile
- Defined in:
- lib/command/cacheable/cachefile.rb
Overview
A file that has a pathname and output $$$ todo: cache error
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#pathname ⇒ Object
readonly
Returns the value of attribute pathname.
Instance Method Summary collapse
-
#initialize(cache_dir, args) ⇒ CacheFile
constructor
A new instance of CacheFile.
- #read ⇒ Object
- #save(output) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(cache_dir, args) ⇒ CacheFile
Returns a new instance of CacheFile.
15 16 17 18 19 20 21 |
# File 'lib/command/cacheable/cachefile.rb', line 15 def initialize cache_dir, args @args = args basename = FileName.new(args).name fullname = Pathname(cache_dir) + basename @pathname = GzipPathname.new fullname @output = nil end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
12 13 14 |
# File 'lib/command/cacheable/cachefile.rb', line 12 def output @output end |
#pathname ⇒ Object (readonly)
Returns the value of attribute pathname.
13 14 15 |
# File 'lib/command/cacheable/cachefile.rb', line 13 def pathname @pathname end |
Instance Method Details
#read ⇒ Object
23 24 25 |
# File 'lib/command/cacheable/cachefile.rb', line 23 def read @output = @pathname.exist? && @pathname.read_file end |
#save(output) ⇒ Object
27 28 29 |
# File 'lib/command/cacheable/cachefile.rb', line 27 def save output @pathname.save_file output end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/command/cacheable/cachefile.rb', line 31 def to_s @pathname.to_s end |