Class: MultipleFilesGzipReader
- Inherits:
-
Object
- Object
- MultipleFilesGzipReader
- Includes:
- Enumerable
- Defined in:
- lib/multiple_files_gzip_reader.rb,
lib/multiple_files_gzip_reader/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Instance Method Summary collapse
- #each(*args, &block) ⇒ Object (also: #each_line)
-
#initialize(io, options = {}) ⇒ MultipleFilesGzipReader
constructor
A new instance of MultipleFilesGzipReader.
- #readlines(*args) ⇒ Object
- #rewind ⇒ Object
Constructor Details
#initialize(io, options = {}) ⇒ MultipleFilesGzipReader
7 8 9 10 |
# File 'lib/multiple_files_gzip_reader.rb', line 7 def initialize(io, = {}) @io = io = end |
Instance Method Details
#each(*args, &block) ⇒ Object Also known as: each_line
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/multiple_files_gzip_reader.rb', line 16 def each(*args, &block) loop do gzip_reader = Zlib::GzipReader.new(io, ) gzip_reader.each_line(*args, &block) unused = gzip_reader.unused gzip_reader.finish io.pos -= unused ? unused.length : 0 break if io.pos == io.size end end |
#readlines(*args) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/multiple_files_gzip_reader.rb', line 32 def readlines(*args) result = [] loop do gzip_reader = Zlib::GzipReader.new(io, ) result.concat gzip_reader.readlines(*args) unused = gzip_reader.unused gzip_reader.finish io.pos -= unused ? unused.length : 0 break if io.pos == io.size end result end |
#rewind ⇒ Object
12 13 14 |
# File 'lib/multiple_files_gzip_reader.rb', line 12 def rewind io.pos = 0 end |