U:RDoc::AnyMethod[iI"new:ETI"Zlib::Deflate::new;TT: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"OCreates a new deflate stream for compression. If a given argument is nil, ;TI"0the default value of that argument is used.;To:RDoc::Markup::BlankLineo; ; [I"QThe +level+ sets the compression level for the deflate stream between 0 (no ;TI"Ncompression) and 9 (best compression). The following constants have been ;TI"(defined to make code more readable:;T@o:RDoc::Markup::List: @type: BULLET: @items[ o:RDoc::Markup::ListItem: @label0; [o; ; [I"Zlib::DEFAULT_COMPRESSION;To;;0; [o; ; [I"Zlib::NO_COMPRESSION;To;;0; [o; ; [I"Zlib::BEST_SPEED;To;;0; [o; ; [I"Zlib::BEST_COMPRESSION;T@o; ; [I"KSee http://www.zlib.net/manual.html#Constants for further information.;T@o; ; [I"QThe +window_bits+ sets the size of the history buffer and should be between ;TI"P8 and 15. Larger values of this parameter result in better compression at ;TI"!the expense of memory usage.;T@o; ; [ I"KThe +mem_level+ specifies how much memory should be allocated for the ;TI"Pinternal compression state. 1 uses minimum memory but is slow and reduces ;TI"Kcompression ratio while 9 uses maximum memory for optimal speed. The ;TI"3default value is 8. Two constants are defined:;T@o; ; ;;[o;;0; [o; ; [I"Zlib::DEF_MEM_LEVEL;To;;0; [o; ; [I"Zlib::MAX_MEM_LEVEL;T@o; ; [I"JThe +strategy+ sets the deflate compression strategy. The following ;TI"strategies are available:;T@o; ; : NOTE;[ o;;[I"Zlib::DEFAULT_STRATEGY;T; [o; ; [I"For normal data;To;;[I"Zlib::FILTERED;T; [o; ; [I"/For data produced by a filter or predictor;To;;[I"Zlib::FIXED;T; [o; ; [I"#Prevents dynamic Huffman codes;To;;[I"Zlib::HUFFMAN_ONLY;T; [o; ; [I"Prevents string matching;To;;[I"Zlib::RLE;T; [o; ; [I"6Designed for better compression of PNG image data;T@o; ; [I"/See the constants for further description.;T@S:RDoc::Markup::Heading: leveli: textI" Examples;T@S;;i;I" Basic;T@o:RDoc::Markup::Verbatim; [I"*open "compressed.file", "w+" do |io| ;TI"> io << Zlib::Deflate.new.deflate(File.read("big.file")) ;TI" end ;T: @format0S;;i;I"Custom compression;T@o;; [I"5open "compressed.file", "w+" do |compressed_io| ;TI"; deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION, ;TI"4 Zlib::MAX_WBITS, ;TI"8 Zlib::MAX_MEM_LEVEL, ;TI"7 Zlib::HUFFMAN_ONLY) ;TI" ;TI" begin ;TI"% open "big.file" do |big_io| ;TI" until big_io.eof? do ;TI"= compressed_io << zd.deflate(big_io.read(16384)) ;TI" end ;TI" end ;TI" ensure ;TI" deflate.close ;TI" end ;TI" end ;T;0o; ; [I"NWhile this example will work, for best optimization review the flags for ;TI"Dyour specific time, memory usage and output space requirements.;T: @fileI"ext/zlib/zlib.c;T:0@omit_headings_from_table_of_contents_below0I"}Zlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY) ;T0[I")(p1 = v1, p2 = v2, p3 = v3, p4 = v4);T@FI" Deflate;TcRDoc::NormalClass00