Class: Zlib::Deflate
Overview
Zlib::Deflate is the class for compressing data. See Zlib::Stream for more information.
Class Method Summary collapse
-
.Zlib::Deflate.deflate(string[, level]) ⇒ Object
Compresses the given
string.
Instance Method Summary collapse
-
#<<(string) ⇒ Object
Inputs
stringinto the deflate stream just like Zlib::Deflate#deflate, but returns the Zlib::Deflate object itself. -
#deflate(string[, flush]) ⇒ Object
Inputs
stringinto the deflate stream and returns the output from the stream. -
#flush(flush) ⇒ Object
This method is equivalent to
deflate('', flush). -
#Zlib::Deflate.new(level = nil, windowBits = nil, memlevel = nil, strategy = nil) ⇒ Object
constructor
Creates a new deflate stream for compression.
-
#initialize_copy ⇒ Object
Duplicates the deflate stream.
-
#params(level, strategy) ⇒ Object
Changes the parameters of the deflate stream.
-
#set_dictionary(string) ⇒ Object
Sets the preset dictionary and returns
string.
Methods inherited from ZStream
#adler, #avail_in, #avail_out, #avail_out=, #close, #closed?, #data_type, #end, #ended?, #finish, #finished?, #flush_next_in, #flush_next_out, #reset, #stream_end?, #total_in, #total_out
Constructor Details
#Zlib::Deflate.new(level = nil, windowBits = nil, memlevel = nil, strategy = nil) ⇒ Object
Creates a new deflate stream for compression. See zlib.h for details of each argument. If an argument is nil, the default value of that argument is used.
TODO: document better!
1154 1155 1156 |
# File 'zlib.c', line 1154 static VALUE rb_deflate_initialize(argc, argv, obj) int argc; |
Class Method Details
.Zlib::Deflate.deflate(string[, level]) ⇒ Object
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?
1229 1230 1231 |
# File 'zlib.c', line 1229 static VALUE rb_deflate_s_deflate(argc, argv, klass) int argc; |
Instance Method Details
#<<(string) ⇒ Object
Inputs string into the deflate stream just like Zlib::Deflate#deflate, but returns the Zlib::Deflate object itself. The output from the stream is preserved in output buffer.
1313 1314 1315 |
# File 'zlib.c', line 1313 static VALUE rb_deflate_addstr(obj, src) VALUE obj, src; |
#deflate(string[, flush]) ⇒ Object
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.
The value of flush should be either Zlib::NO_FLUSH, Zlib::SYNC_FLUSH, Zlib::FULL_FLUSH, or Zlib::FINISH. See zlib.h for details.
TODO: document better!
1288 1289 1290 |
# File 'zlib.c', line 1288 static VALUE rb_deflate_deflate(argc, argv, obj) int argc; |
#flush(flush) ⇒ Object
This method is equivalent to deflate('', flush). If flush is omitted, Zlib::SYNC_FLUSH is used as flush. This method is just provided to improve the readability of your Ruby program.
TODO: document better!
1331 1332 1333 |
# File 'zlib.c', line 1331 static VALUE rb_deflate_flush(argc, argv, obj) int argc; |
#initialize_copy ⇒ Object
Duplicates the deflate stream.
1181 1182 1183 |
# File 'zlib.c', line 1181 static VALUE rb_deflate_init_copy(self, orig) VALUE self, orig; |
#params(level, strategy) ⇒ Object
Changes the parameters of the deflate stream. See zlib.h for details. The output from the stream by changing the params is preserved in output buffer.
TODO: document better!
1361 1362 1363 |
# File 'zlib.c', line 1361 static VALUE rb_deflate_params(obj, v_level, v_strategy) VALUE obj, v_level, v_strategy; |
#set_dictionary(string) ⇒ Object
Sets the preset dictionary and returns string. This method is available just only after Zlib::Deflate.new or Zlib::ZStream#reset method was called. See zlib.h for details.
TODO: document better!
1394 1395 1396 |
# File 'zlib.c', line 1394 static VALUE rb_deflate_set_dictionary(obj, dic) VALUE obj, dic; |