Method: Zstdlib::Deflate#deflate

Defined in:
ext/zstdlib_c/ruby/zlib-3.2/zstdlib.c,
ext/zstdlib_c/ruby/zlib-3.1/zstdlib.c,
ext/zstdlib_c/ruby/zlib-3.0/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.7/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.6/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.5/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.4/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.3/zstdlib.c,
ext/zstdlib_c/ruby/zlib-2.2/zstdlib.c

#deflate(*args) ⇒ Object

call-seq: z.deflate(string, flush = Zstdlib::NO_FLUSH) -> String z.deflate(string, flush = Zstdlib::NO_FLUSH) { |chunk| ... } -> nil

Inputs +string+ into the deflate stream and returns the output from the stream. On calling this method, both the input and the output buffers of the stream are flushed. If +string+ is nil, this method finishes the stream, just like Zstdlib::ZStream#finish.

If a block is given consecutive deflated chunks from the +string+ are yielded to the block and +nil+ is returned.

The +flush+ parameter specifies the flush mode. The following constants may be used:

Zstdlib::NO_FLUSH:: The default Zstdlib::SYNC_FLUSH:: Flushes the output to a byte boundary Zstdlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state Zstdlib::FINISH:: Pending input is processed, pending output is flushed.

See the constants for further description.



1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
# File 'ext/zstdlib_c/ruby/zlib-3.2/zstdlib.c', line 1809

static VALUE
rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
{
    struct zstream *z = get_zstream(obj);
    VALUE src, flush;

    rb_scan_args(argc, argv, "11", &src, &flush);
    do_deflate(z, src, ARG_FLUSH(flush));

    return zstream_detach_buffer(z);
}