Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Zlib.gunzip

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.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0