Archive::Zip::Codec::Deflate::Decompress extends Zlib::ZReader in order to specify the standard Zlib options required by ZIP archives and to provide a close method which can optionally close the delegate IO-like object. In addition a convenience method is provided for generating DataDescriptor objects based on the data which is passed through this object.
Instances of this class should only be accessed via the Archive::Zip::Codec::Deflate#decompressor method.
Creates a new instance of this class using io as a data source. io must be readable and provide a read method as IO does or errors will be raised when performing read operations. If io provides a rewind method, this class' rewind method will be enabled.
# File lib/archive/zip/codec/deflate.rb, line 117 def initialize(io) super(io, -Zlib::MAX_WBITS) @crc32 = 0 end
Creates a new instance of this class with the given arguments 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/deflate.rb, line 102 def self.open(io) inflate_io = new(io) return inflate_io unless block_given? begin yield(inflate_io) ensure inflate_io.close unless inflate_io.closed? end end
Closes this object so that further read operations will fail. If close_delegate is true, the delegate object used as a data source will also be closed using its close method.
# File lib/archive/zip/codec/deflate.rb, line 133 def close(close_delegate = true) super() delegate.close if close_delegate end
Returns an instance of Archive::Zip::DataDescriptor with information regarding the data which has passed through this object from the delegate object. It is recommended to call the close method before calling this in order to ensure that no further read operations change the state of this object.
# File lib/archive/zip/codec/deflate.rb, line 143 def data_descriptor DataDescriptor.new(crc32, compressed_size, uncompressed_size) end
Generated with the Darkfish Rdoc Generator 2.