Class: Rant::Archive::Rubyzip::PassThruDecompressor

Inherits:
Decompressor show all
Defined in:
lib/rant/archive/rubyzip.rb

Overview

:nodoc:all

Constant Summary

Constants inherited from Decompressor

Decompressor::CHUNK_SIZE

Instance Method Summary collapse

Constructor Details

#initialize(inputStream, charsToRead) ⇒ PassThruDecompressor

Returns a new instance of PassThruDecompressor.



243
244
245
246
247
248
# File 'lib/rant/archive/rubyzip.rb', line 243

def initialize(inputStream, charsToRead)
  super inputStream
  @charsToRead = charsToRead
  @readSoFar = 0
  @hasReturnedEmptyString = ! EMPTY_FILE_RETURNS_EMPTY_STRING_FIRST
end

Instance Method Details

#input_finished?Boolean

Returns:

  • (Boolean)


270
271
272
# File 'lib/rant/archive/rubyzip.rb', line 270

def input_finished?
  (@readSoFar >= @charsToRead)
end

#produce_inputObject



266
267
268
# File 'lib/rant/archive/rubyzip.rb', line 266

def produce_input
  read(Decompressor::CHUNK_SIZE)
end

#read(numberOfBytes = nil) ⇒ Object

TODO: Specialize to handle different behaviour in ruby > 1.7.0 ?



251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/rant/archive/rubyzip.rb', line 251

def read(numberOfBytes = nil)
  if input_finished?
	hasReturnedEmptyStringVal=@hasReturnedEmptyString
	@hasReturnedEmptyString=true
	return "" unless hasReturnedEmptyStringVal
	return nil
  end
  
  if (numberOfBytes == nil || @readSoFar+numberOfBytes > @charsToRead)
	numberOfBytes = @charsToRead-@readSoFar
  end
  @readSoFar += numberOfBytes
  @inputStream.read(numberOfBytes)
end