Skip to content
class method

Zlib::Deflate.deflate

(::string string, ?::Zlib::Deflate::compression_level level) -> ::String
Zlib.deflate(string[, level])
Zlib::Deflate.deflate(string[, level])

Compresses the given string. Valid values of level are Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, or an integer from 0 to 9.

This method is almost equivalent to the following code:

Example
def deflate(string, level)
  z = Zlib::Deflate.new(level)
  dst = z.deflate(string, Zlib::FINISH)
  z.close
  dst
end

See also Zlib.inflate

See also #deflate .new #<< also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0