Parent

Methods

Included Modules

Archive::Zip::Codec::NullEncryption::Encrypt

Archive::Zip::Codec::NullEncryption::Encrypt is a writable, IO-like object which writes all data written to it directly to a delegate IO object. A close method is also provided which can optionally closed the delegate object.

Public Class Methods

new(io) click to toggle source

Creates a new instance of this class using io as a data sink. io must be writable and must provide a write method as IO does or errors will be raised when performing write operations.

The flush_size attribute is set to 0 by default under the assumption that io is already buffered.

# File lib/archive/zip/codec/null_encryption.rb, line 38
def initialize(io)
  @io = io

  # Keep track of the total number of bytes written.
  @total_bytes_in = 0

  # Assume that the delegate IO object is already buffered.
  self.flush_size = 0
end
open(io) click to toggle source

Creates a new instance of this class with the given argument using new and then passes the instance to the given block. The close method is guaranteed to be called after the block completes.

Equivalent to new if no block is given.

# File lib/archive/zip/codec/null_encryption.rb, line 21
def self.open(io)
  encrypt_io = new(io)
  return encrypt_io unless block_given?

  begin
    yield(encrypt_io)
  ensure
    encrypt_io.close unless encrypt_io.closed?
  end
end

Public Instance Methods

close(close_delegate = true) click to toggle source

Closes this object so that further write operations will fail. If close_delegate is true, the delegate object used as a data sink will also be closed using its close method.

# File lib/archive/zip/codec/null_encryption.rb, line 51
def close(close_delegate = true)
  super()
  @io.close if close_delegate
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.