From: "drbrain (Eric Hodel)" Date: 2012-04-10T05:16:20+09:00 Subject: [ruby-core:44235] [ruby-trunk - Bug #6273] confusing rdoc on Zlib Issue #6273 has been updated by drbrain (Eric Hodel). Category set to DOC Assignee set to drbrain (Eric Hodel) ---------------------------------------- Bug #6273: confusing rdoc on Zlib https://bugs.ruby-lang.org/issues/6273#change-25761 Author: lparra (Luis Parravicini) Status: Open Priority: Normal Assignee: drbrain (Eric Hodel) Category: DOC Target version: ruby -v: trunk =begin The rdoc at ext/zlib/zlib.c gives some examples of code to deflate/inflate a string. If you try to use them to actually deflate/inflate it gives an error inflating. The deflate snippet is: def deflate(string, level) z = Zlib::Deflate.new(level) dst = z.deflate(string, Zlib::NO_FLUSH) z.close dst end And the inflate snippet is: def inflate(string) zstream = Zlib::Inflate.new buf = zstream.inflate(string) zstream.finish zstream.close buf end And then testing them with: inflate(deflate("test-string", 6)) It returns "Zlib::BufError: buffer error". The error is because the flush parameter used is NO_FLUSH. It should be changed to FINISH for the deflating/inflating to work. =end -- http://bugs.ruby-lang.org/