instance method
Zlib::Deflate#deflate
(::string string, ?::Integer flush) -> ::String
(::string string, ?::Integer flush) { (::String chunk) -> nil } -> nil
z.deflate(string, flush = Zlib::NO_FLUSH) → String
z.deflate(string, flush = Zlib::NO_FLUSH) { |chunk| ... } → nil
ext/zlib/zlib.c
View on GitHub ↗
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);
struct rb_zlib_deflate_arguments arguments = {z, src, ARG_FLUSH(flush)};
return rb_mutex_synchronize(z->mutex, rb_deflate_deflate_body, (VALUE)&arguments);
}
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 Zlib::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:
Zlib::NO_FLUSH-
The default
Zlib::SYNC_FLUSH-
Flushes the output to a byte boundary
Zlib::FULL_FLUSH-
SYNC_FLUSH + resets the compression state
Zlib::FINISH-
Pending input is processed, pending output is flushed.
See the constants for further description.