Class: Zip::PassThruDecompressor
- Inherits:
-
Decompressor
- Object
- Decompressor
- Zip::PassThruDecompressor
- Defined in:
- lib/ruby_archive/handlers/rubyzip/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 (also: #eof, #eof?)
- #produce_input ⇒ Object
-
#sysread(numberOfBytes = nil, buf = 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.
236 237 238 239 240 241 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 236 def initialize(inputStream, charsToRead) super inputStream @charsToRead = charsToRead @readSoFar = 0 @hasReturnedEmptyString = ! EMPTY_FILE_RETURNS_EMPTY_STRING_FIRST end |
Instance Method Details
#input_finished? ⇒ Boolean Also known as: eof, eof?
263 264 265 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 263 def input_finished? (@readSoFar >= @charsToRead) end |
#produce_input ⇒ Object
259 260 261 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 259 def produce_input sysread(Decompressor::CHUNK_SIZE) end |
#sysread(numberOfBytes = nil, buf = nil) ⇒ Object
TODO: Specialize to handle different behaviour in ruby > 1.7.0 ?
244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/ruby_archive/handlers/rubyzip/zip/zip.rb', line 244 def sysread(numberOfBytes = nil, buf = 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, buf) end |