Class: Zip::DecryptedIo

Inherits:
Object
  • Object
show all
Defined in:
lib/zip/crypto/decrypted_io.rb

Overview

:nodoc:all

Constant Summary collapse

CHUNK_SIZE =
32_768

Instance Method Summary collapse

Constructor Details

#initialize(io, decrypter) ⇒ DecryptedIo

Returns a new instance of DecryptedIo.



7
8
9
10
# File 'lib/zip/crypto/decrypted_io.rb', line 7

def initialize(io, decrypter)
  @io = io
  @decrypter = decrypter
end

Instance Method Details

#read(length = nil, outbuf = +'')) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/zip/crypto/decrypted_io.rb', line 12

def read(length = nil, outbuf = +'')
  return (length.nil? || length.zero? ? '' : nil) if eof

  while length.nil? || (buffer.bytesize < length)
    break if input_finished?

    buffer << produce_input
  end

  outbuf.replace(buffer.slice!(0...(length || output_buffer.bytesize)))
end