Class: Zip::DecryptedIo
- Inherits:
-
Object
- Object
- Zip::DecryptedIo
- Defined in:
- lib/zip/crypto/decrypted_io.rb
Overview
:nodoc:all
Constant Summary collapse
- CHUNK_SIZE =
32_768
Instance Method Summary collapse
-
#initialize(io, decrypter, compressed_size) ⇒ DecryptedIo
constructor
A new instance of DecryptedIo.
- #read(maxlen = nil) ⇒ Object
Constructor Details
#initialize(io, decrypter, compressed_size) ⇒ DecryptedIo
Returns a new instance of DecryptedIo.
7 8 9 10 11 12 |
# File 'lib/zip/crypto/decrypted_io.rb', line 7 def initialize(io, decrypter, compressed_size) @io = io @decrypter = decrypter @bytes_remaining = compressed_size @buffer = +''.b end |
Instance Method Details
#read(maxlen = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/zip/crypto/decrypted_io.rb', line 14 def read(maxlen = nil) return (maxlen.nil? || maxlen.zero? ? '' : nil) if eof? while maxlen.nil? || (@buffer.bytesize < maxlen) break if input_finished? @buffer << produce_input end @decrypter.check_integrity!(@io) if input_finished? @buffer.slice!(0...(maxlen || @buffer.bytesize)) end |