Flowdock
new(p1 = v1) public

Creates a new inflate stream for decompression. window_bits sets the size of the history buffer and can have the following values:

0

Have inflate use the window size from the zlib header of the compressed stream.

(8..15)

Overrides the window size of the inflate header in the compressed stream. The window size must be greater than or equal to the window size of the compressed stream.

Greater than 15

Add 32 to window_bits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (a Zlib::DataError will be raised for a non-gzip stream).

(-8..-15)

Enables raw deflate mode which will not generate a check value, and will not look for any check values for comparison at the end of the stream.

This is for use with other formats that use the deflate compressed data format such as zip which provide their own check values.

Example

open "compressed.file" do |compressed_io|
  zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32)

  begin
    open "uncompressed.file", "w+" do |uncompressed_io|
      uncompressed_io << zi.inflate(compressed_io.read)
    end
  ensure
    zi.close
  end
end
Show source
Register or log in to add new notes.