Class: Zip::Inflater
- Inherits:
-
Decompressor
- Object
- Decompressor
- Zip::Inflater
- Defined in:
- lib/zip/inflater.rb
Overview
:nodoc:all
Constant Summary
Constants inherited from Decompressor
Instance Attribute Summary
Attributes inherited from Decompressor
#decompressed_size, #input_stream
Instance Method Summary collapse
- #eof ⇒ Object (also: #eof?)
-
#initialize(*args) ⇒ Inflater
constructor
A new instance of Inflater.
- #read(length = nil, outbuf = '') ⇒ Object
Methods inherited from Decompressor
decompressor_classes, find_by_compression_method, register
Constructor Details
#initialize(*args) ⇒ Inflater
Returns a new instance of Inflater.
3 4 5 6 7 8 |
# File 'lib/zip/inflater.rb', line 3 def initialize(*args) super @buffer = +'' @zlib_inflater = ::Zlib::Inflate.new(-Zlib::MAX_WBITS) end |
Instance Method Details
#eof ⇒ Object Also known as: eof?
22 23 24 |
# File 'lib/zip/inflater.rb', line 22 def eof @buffer.empty? && input_finished? end |
#read(length = nil, outbuf = '') ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/zip/inflater.rb', line 10 def read(length = nil, outbuf = '') return (length.nil? || length.zero? ? '' : nil) if eof while length.nil? || (@buffer.bytesize < length) break if input_finished? @buffer << produce_input end outbuf.replace(@buffer.slice!(0...(length || @buffer.bytesize))) end |