Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

Zlib::GzipFile.wrap

(::IO io, *untyped) { (instance gz) -> void } -> void
Zlib::GzipReader.wrap(io, ...) { |gz| ... }
Zlib::GzipWriter.wrap(io, ...) { |gz| ... }

Creates a GzipReader or GzipWriter associated with io, passing in any necessary extra options, and executes the block with the newly created object just like File.open.

The GzipFile object will be closed automatically after executing the block. If you want to keep the associated IO object open, you may call Zlib::GzipFile#finish method in the block.

See also #close #closed? also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0