class AWS::S3::CipherIO

@private

Public Class Methods

new(cipher, stream, stream_size = nil) click to toggle source
# File lib/aws/s3/cipher_io.rb, line 20
def initialize cipher, stream, stream_size = nil

  @stream = stream
  @stream_size = stream_size
  @orig_cipher = cipher.clone

  reset_cipher

  # add a #rewind method if the original stream can be rewound
  if @stream.respond_to?(:rewind)
    Core::MetaUtils.extend_method(self, :rewind) do
      reset_cipher
      @stream.rewind
    end
  end

  # add a #size method if the stream size is known
  if stream_size
    Core::MetaUtils.extend_method(self, :size) do
      EncryptionUtils.get_encrypted_size(@stream_size)
    end
  end

end

Public Instance Methods

eof?() click to toggle source

@return [Boolean] Returns true when the entire stream has been read.

# File lib/aws/s3/cipher_io.rb, line 56
def eof?
  @eof
end
read(bytes = nil) click to toggle source

@return [String] Returns the requested number of bytes. If no byte

amount is given, it will return the entire body of encrypted data
# File lib/aws/s3/cipher_io.rb, line 47
def read bytes = nil
  if bytes
    (@eof) ? nil : read_chunk(bytes)
  else
    (@eof) ? ""  : read_all()
  end
end