Class: System::CacheFile
- Inherits:
-
Object
- Object
- System::CacheFile
- Includes:
- Loggable
- Defined in:
- lib/system/command/cachefile.rb
Instance Method Summary collapse
-
#initialize(cache_dir, args) ⇒ CacheFile
constructor
A new instance of CacheFile.
- #readlines ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(cache_dir, args) ⇒ CacheFile
Returns a new instance of CacheFile.
10 11 12 13 14 15 16 |
# File 'lib/system/command/cachefile.rb', line 10 def initialize cache_dir, args # pwd = Pathname.pwd.split_path.join('') # info "pwd: #{pwd}" @args = args @pn = Pathname.new(cache_dir) + args.join('-').gsub('/', '\/') info "pn: #{@pn}".yellow end |
Instance Method Details
#readlines ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/system/command/cachefile.rb', line 18 def readlines if @pn.exist? info "reading from cache file: #{@pn}".cyan @pn.readlines else cl = CommandLine.new @args output = cl.execute @pn.parent.mkpath info "saving output to cache file: #{@pn}" File.put_via_temp_file @pn.to_s do output end output end end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/system/command/cachefile.rb', line 35 def to_s @pn.to_s end |