deflate(p1, p2 = v2)
  public
  
    
    
Compresses the given string. Valid values of level are
Zlib::NO_COMPRESSION, Zlib::BEST_SPEED,
Zlib::BEST_COMPRESSION, Zlib::DEFAULT_COMPRESSION, and an
integer from 0 to 9.
This method is almost equivalent to the following code:
def deflate(string, level)
  z = Zlib::Deflate.new(level)
  dst = z.deflate(string, Zlib::FINISH)
  z.close
  dst
end
TODO: what’s default value of level?
   
  
    Show source    
    
      static VALUE
rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass)
{
    struct zstream z;
    VALUE src, level, dst, args[2];
    int err, lev;
    rb_scan_args(argc, argv, "11", &src, &level);
    lev = ARG_LEVEL(level);
    StringValue(src);
    zstream_init_deflate(&z);
    err = deflateInit(&z.stream, lev);
    if (err != Z_OK) {
        raise_zlib_error(err, z.stream.msg);
    }
    ZSTREAM_READY(&z);
    args[0] = (VALUE)&z;
    args[1] = src;
    dst = rb_ensure(deflate_run, (VALUE)args, zstream_end, (VALUE)&z);
    OBJ_INFECT(dst, src);
    return dst;
}