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 Method Summary collapse
-
#initialize(input_stream, decrypter = NullDecrypter.new) ⇒ Inflater
constructor
A new instance of Inflater.
-
#input_finished? ⇒ Boolean
(also: #eof, #eof?)
to be used with produce_input, not read (as read may still have more data cached) is data cached anywhere other than @outputBuffer? the comment above may be wrong.
- #produce_input ⇒ Object
- #sysread(number_of_bytes = nil, buf = '') ⇒ Object
Constructor Details
#initialize(input_stream, decrypter = NullDecrypter.new) ⇒ Inflater
Returns a new instance of Inflater.
3 4 5 6 7 8 9 |
# File 'lib/zip/inflater.rb', line 3 def initialize(input_stream, decrypter = NullDecrypter.new) super(input_stream) @zlib_inflater = ::Zlib::Inflate.new(-Zlib::MAX_WBITS) @output_buffer = '' @has_returned_empty_string = false @decrypter = decrypter end |
Instance Method Details
#input_finished? ⇒ Boolean Also known as: eof, eof?
to be used with produce_input, not read (as read may still have more data cached) is data cached anywhere other than @outputBuffer? the comment above may be wrong
32 33 34 |
# File 'lib/zip/inflater.rb', line 32 def input_finished? @output_buffer.empty? && internal_input_finished? end |
#produce_input ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/zip/inflater.rb', line 22 def produce_input if @output_buffer.empty? internal_produce_input else @output_buffer.slice!(0...(@output_buffer.length)) end end |
#sysread(number_of_bytes = nil, buf = '') ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/zip/inflater.rb', line 11 def sysread(number_of_bytes = nil, buf = '') readEverything = number_of_bytes.nil? while readEverything || @output_buffer.bytesize < number_of_bytes break if internal_input_finished? @output_buffer << internal_produce_input(buf) end return value_when_finished if @output_buffer.bytesize == 0 && input_finished? end_index = number_of_bytes.nil? ? @output_buffer.bytesize : number_of_bytes @output_buffer.slice!(0...end_index) end |