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.


3
4
5
6
# File 'lib/zip/pass_thru_decompressor.rb', line 3

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

Instance Method Details

#eofObject Also known as: eof?


19
20
21
# File 'lib/zip/pass_thru_decompressor.rb', line 19

def eof
  @read_so_far >= decompressed_size
end

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


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

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