Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Zlib.gunzip

(::String) -> ::String
Zlib.gunzip(src) → String

Decode the given gzipped string.

This method is almost equivalent to the following code:

Example
def gunzip(string)
  sio = StringIO.new(string)
  gz = Zlib::GzipReader.new(sio, encoding: Encoding::ASCII_8BIT)
  gz.read
ensure
  gz&.close
end

See also Zlib.gzip

See also .deflate .gzip .crc_table .inflate also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0