Class: Zip::PassThruDecompressor
- Inherits:
-
Decompressor
- Object
- Decompressor
- Zip::PassThruDecompressor
- Defined in:
- lib/zip/zip.rb
Overview
:nodoc:all
Constant Summary
Constants inherited from Decompressor
Instance Method Summary collapse
-
#initialize(inputStream, charsToRead) ⇒ PassThruDecompressor
constructor
A new instance of PassThruDecompressor.
- #input_finished? ⇒ Boolean
- #produce_input ⇒ Object
-
#read(numberOfBytes = nil) ⇒ Object
TODO: Specialize to handle different behaviour in ruby > 1.7.0 ?.
Constructor Details
#initialize(inputStream, charsToRead) ⇒ PassThruDecompressor
Returns a new instance of PassThruDecompressor.
216 217 218 219 220 221 |
# File 'lib/zip/zip.rb', line 216 def initialize(inputStream, charsToRead) super inputStream @charsToRead = charsToRead @readSoFar = 0 @hasReturnedEmptyString = ! EMPTY_FILE_RETURNS_EMPTY_STRING_FIRST end |
Instance Method Details
#input_finished? ⇒ Boolean
243 244 245 |
# File 'lib/zip/zip.rb', line 243 def input_finished? (@readSoFar >= @charsToRead) end |
#produce_input ⇒ Object
239 240 241 |
# File 'lib/zip/zip.rb', line 239 def produce_input read(Decompressor::CHUNK_SIZE) end |
#read(numberOfBytes = nil) ⇒ Object
TODO: Specialize to handle different behaviour in ruby > 1.7.0 ?
224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/zip/zip.rb', line 224 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 |