Class

Zlib::Deflate

Inheritance
< Zlib::ZStream < Object

Zlib::Deflate is the class for compressing data. See Zlib::Stream for more information.

Methods

Class

Visibility Signature
public deflate (...)
public new (...)

Instance

Visibility Signature
public << (p1)
public deflate (...)
public flush (...)
public initialize_copy ()
public params (p1, p2)
public set_dictionary (p1)

Class Method Detail

Zlib::Deflate.deflate(string[, level])

Compresses the given string. Valid values of level are Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and an integer from 0 to 9.

This method is almost equivalent to the following code:

  def deflate(string, level)
    z = Zlib::Deflate.new(level)
    dst = z.deflate(string, Zlib::FINISH)
    z.close
    dst
  end

TODO: what‘s default value of level?

Zlib::Deflate.new(level=nil, windowBits=nil, memlevel=nil, strategy=nil)

Creates a new deflate stream for compression. See zlib.h for details of each argument. If an argument is nil, the default value of that argument is used.

TODO: document better!

Instance Method Detail

<<(p1)

Same as IO.

deflate(string[, flush])

Inputs string into the deflate stream and returns the output from the stream. On calling this method, both the input and the output buffers of the stream are flushed. If string is nil, this method finishes the stream, just like Zlib::ZStream#finish.

The value of flush should be either Zlib::NO_FLUSH, Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or Zlib::FINISH. See zlib.h for details.

TODO: document better!

flush(flush)

This method is equivalent to deflate(’’, flush). If flush is omitted, Zlib::SYNC_FLUSH is used as flush. This method is just provided to improve the readability of your Ruby program.

TODO: document better!

initialize_copy()

Duplicates the deflate stream.

params(level, strategy)

Changes the parameters of the deflate stream. See zlib.h for details. The output from the stream by changing the params is preserved in output buffer.

TODO: document better!

set_dictionary(string)

Sets the preset dictionary and returns string. This method is available just only after Zlib::Deflate.new or Zlib::ZStream#reset method was called. See zlib.h for details.

TODO: document better!