Class: Zip::Inflater

Inherits:
Decompressor show all
Defined in:
lib/zip/zip.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.



110
111
112
113
114
115
# File 'lib/zip/zip.rb', line 110

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

to be used with produce_input, not read (as read may still have more data cached)

Returns:

  • (Boolean)


137
138
139
# File 'lib/zip/zip.rb', line 137

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

#produce_inputObject



128
129
130
131
132
133
134
# File 'lib/zip/zip.rb', line 128

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

#read(numberOfBytes = nil) ⇒ Object



117
118
119
120
121
122
123
124
125
126
# File 'lib/zip/zip.rb', line 117

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