Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
Zlib::Inflate#inflate
static VALUE
rb_inflate_inflate(int argc, VALUE* argv, VALUE obj)
{
struct zstream *z = get_zstream(obj);
struct rb_zlib_inflate_arguments arguments = {z, argc, argv};
return rb_mutex_synchronize(z->mutex, rb_inflate_inflate_body, (VALUE)&arguments);
}
Inputs deflate_string into the inflate stream and returns the output from the stream. Calling this method, both the input and the output buffer of the stream are flushed. If string is nil, this method finishes the stream, just like Zlib::ZStream#finish.
If a block is given consecutive inflated chunks from the deflate_string are yielded to the block and nil is returned.
If a :buffer keyword argument is given and not nil:
-
The :buffer keyword should be a
String, and will used as the output buffer. Using this option can reuse the memory required during inflation. -
When not passing a block, the return value will be the same object as the :buffer keyword argument.
-
When passing a block, the yielded chunks will be the same value as the :buffer keyword argument.
Raises a Zlib::NeedDict exception if a preset dictionary is needed to decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then call this method again with an empty string to flush the stream:
inflater = Zlib::Inflate.new begin out = inflater.inflate compressed rescue Zlib::NeedDict # ensure the dictionary matches the stream's required dictionary raise unless inflater.adler == Zlib.adler32(dictionary) inflater.set_dictionary dictionary inflater.inflate '' end # ... inflater.close
See also Zlib::Inflate.new