Class: Zip::PassThruDecompressor
- Inherits:
-
Decompressor
- Object
- Decompressor
- Zip::PassThruDecompressor
- Defined in:
- lib/zip/pass_thru_decompressor.rb
Overview
:nodoc:all
Constant Summary
Constants inherited from Decompressor
Instance Method Summary collapse
-
#initialize(input_stream, chars_to_read) ⇒ PassThruDecompressor
constructor
A new instance of PassThruDecompressor.
- #input_finished? ⇒ Boolean (also: #eof, #eof?)
- #produce_input ⇒ Object
- #sysread(number_of_bytes = nil, buf = '') ⇒ Object
Constructor Details
#initialize(input_stream, chars_to_read) ⇒ PassThruDecompressor
Returns a new instance of PassThruDecompressor.
3 4 5 6 7 8 |
# File 'lib/zip/pass_thru_decompressor.rb', line 3 def initialize(input_stream, chars_to_read) super(input_stream) @chars_to_read = chars_to_read @read_so_far = 0 @has_returned_empty_string = false end |
Instance Method Details
#input_finished? ⇒ Boolean Also known as: eof, eof?
29 30 31 |
# File 'lib/zip/pass_thru_decompressor.rb', line 29 def input_finished? @read_so_far >= @chars_to_read end |
#produce_input ⇒ Object
25 26 27 |
# File 'lib/zip/pass_thru_decompressor.rb', line 25 def produce_input sysread(::Zip::Decompressor::CHUNK_SIZE) end |
#sysread(number_of_bytes = nil, buf = '') ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/zip/pass_thru_decompressor.rb', line 10 def sysread(number_of_bytes = nil, buf = '') if input_finished? has_returned_empty_string_val = @has_returned_empty_string @has_returned_empty_string = true return '' unless has_returned_empty_string_val return end if number_of_bytes.nil? || @read_so_far + number_of_bytes > @chars_to_read number_of_bytes = @chars_to_read - @read_so_far end @read_so_far += number_of_bytes @input_stream.read(number_of_bytes, buf) end |