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.


5
6
7
8
# File 'lib/zip/crypto/decrypted_io.rb', line 5

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

Instance Method Details

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


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

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