method

new

v1_9_3_392 - Show latest stable - Class: Zlib::Inflate
new(p1 = v1)
public

Arguments

windowBits

An Integer for the windowBits size. Should be in the range 8..15, larger values of this parameter result in better at the expense of memory usage.

Description

Creates a new inflate stream for decompression. See zlib.h for details of the argument. If window_bits is nil, the default value is used.

Example

cf = File.open("compressed.file")
ucf = File.open("uncompressed.file", "w+")
zi = Zlib::Inflate.new(Zlib::MAX_WBITS)

ucf << zi.inflate(cf.read)

ucf.close
zi.close
cf.close

or

File.open("compressed.file") {|cf|
  zi = Zlib::Inflate.new
  File.open("uncompressed.file", "w+") {|ucf|
    ucf << zi.inflate(cf.read)
  }
  zi.close
}