Class: Zip::PassThruDecompressor

Inherits:
Decompressor show all
Defined in:
lib/zip/pass_thru_decompressor.rb

Overview

:nodoc:all

Constant Summary

Constants inherited from Decompressor

Decompressor::CHUNK_SIZE

Instance Attribute Summary

Attributes inherited from Decompressor

#decompressed_size, #input_stream

Instance Method Summary collapse

Methods inherited from Decompressor

decompressor_classes, find_by_compression_method, register

Constructor Details

#initialize(*args) ⇒ PassThruDecompressor

Returns a new instance of PassThruDecompressor.



5
6
7
8
# File 'lib/zip/pass_thru_decompressor.rb', line 5

def initialize(*args)
  super
  @read_so_far = 0
end

Instance Method Details

#eofObject Also known as: eof?



21
22
23
# File 'lib/zip/pass_thru_decompressor.rb', line 21

def eof
  @read_so_far >= decompressed_size
end

#read(length = nil, outbuf = +'')) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/zip/pass_thru_decompressor.rb', line 10

def read(length = nil, outbuf = +'')
  return (length.nil? || length.zero? ? '' : nil) if eof

  if length.nil? || (@read_so_far + length) > decompressed_size
    length = decompressed_size - @read_so_far
  end

  @read_so_far += length
  input_stream.read(length, outbuf)
end