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

#eof?Boolean Also known as: eof

Returns:

  • (Boolean)


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

def eof?
  @read_so_far >= decompressed_size
end

#read(maxlen = nil) ⇒ Object



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

def read(maxlen = nil)
  return (maxlen.nil? || maxlen.zero? ? '' : nil) if eof?

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

  @read_so_far += maxlen
  input_stream.read(maxlen)
end