Class: CmdLine::GzipPathname
- Inherits:
-
Pathname
- Object
- Pathname
- CmdLine::GzipPathname
- Defined in:
- lib/cmdline/gzpathname.rb
Overview
A pathname that reads and writes itself as gzipped
Instance Method Summary collapse
Instance Method Details
#read_file ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/cmdline/gzpathname.rb', line 18 def read_file Array.new.tap do |content| Zlib::GzipReader.open(to_s) do |gz| content.concat gz.readlines end end end |
#save_file(content) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/cmdline/gzpathname.rb', line 10 def save_file content parent.mkpath unless parent.exist? unlink if exist? Zlib::GzipWriter.open(to_s) do |gz| gz.puts content end end |