Class: Zip::Inflater

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

Overview

:nodoc:all

Constant Summary

Constants inherited from Decompressor

Decompressor::CHUNK_SIZE

Instance Method Summary collapse

Constructor Details

#initialize(inputStream) ⇒ Inflater

Returns a new instance of Inflater.



3
4
5
6
7
8
# File 'lib/zip/inflater.rb', line 3

def initialize(inputStream)
  super
  @zlibInflater = Zlib::Inflate.new(-Zlib::MAX_WBITS)
  @outputBuffer=""
  @hasReturnedEmptyString = ! EMPTY_FILE_RETURNS_EMPTY_STRING_FIRST
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

Returns:

  • (Boolean)


31
32
33
# File 'lib/zip/inflater.rb', line 31

def input_finished?
  @outputBuffer.empty? && internal_input_finished?
end

#produce_inputObject



21
22
23
24
25
26
27
# File 'lib/zip/inflater.rb', line 21

def produce_input
  if (@outputBuffer.empty?)
    return internal_produce_input
  else
    return @outputBuffer.slice!(0...(@outputBuffer.length))
  end
end

#sysread(numberOfBytes = nil, buf = nil) ⇒ Object



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

def sysread(numberOfBytes = nil, buf = nil)
  readEverything = numberOfBytes.nil?
  while (readEverything || @outputBuffer.bytesize < numberOfBytes)
    break if internal_input_finished?
    @outputBuffer << internal_produce_input(buf)
  end
  return value_when_finished if @outputBuffer.bytesize == 0 && input_finished?
  endIndex = numberOfBytes.nil? ? @outputBuffer.bytesize : numberOfBytes
  return @outputBuffer.slice!(0...endIndex)
end