Class: EasyZip::Gzip
- Inherits:
-
Object
- Object
- EasyZip::Gzip
- Defined in:
- lib/easy_zip.rb
Overview
gzip class.
Class Method Summary collapse
-
.read_lines(filepath) ⇒ Array
read all lines in gzip file.
-
.write_lines(filepath, lines) ⇒ Object
write all lines to gzip file.
Class Method Details
.read_lines(filepath) ⇒ Array
read all lines in gzip file.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/easy_zip.rb', line 13 def self.read_lines(filepath) lines = nil # read gzip file, and read all lines. Zlib::GzipReader.open(filepath) { |gz| lines = gz.readlines } lines end |
.write_lines(filepath, lines) ⇒ Object
write all lines to gzip file.
27 28 29 30 31 32 33 34 35 |
# File 'lib/easy_zip.rb', line 27 def self.write_lines(filepath, lines) Zlib::GzipWriter.open(filepath) { |gz| # write to gzip file. lines.each { |line| gz.puts(line) } } end |