summaryrefslogtreecommitdiff
path: root/ext/zlib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-27 01:36:16 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-27 01:36:16 +0000
commite755ecacf904d9376323df32eb837cee9fbfb07f (patch)
tree37a2ee1a020cc44bb862080df98deda1336fb1cf /ext/zlib
parentd298593f56429d97808a15370f0b91aea0ff6bc5 (diff)
Update rdoc of zlib.
Add description about gzip(1) compatible output. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/zlib')
-rw-r--r--ext/zlib/zlib.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 9a04c61bf3..2d63570cac 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -2852,7 +2852,7 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
* Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
* be used with an instance of IO, or IO-like, object.
*
- * For example:
+ * Following two example generate the same result.
*
* Zlib::GzipWriter.open('hoge.gz') do |gz|
* gz.write 'jugemu jugemu gokou no surikire...'
@@ -2864,8 +2864,14 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
* gz.close
* end
*
- * # TODO: test these. Are they equivalent? Can GzipWriter.new take a
- * # block?
+ * To make like gzip(1) does, run following:
+ *
+ * orig = 'hoge.txt'
+ * Zlib::GzipWriter.open('hoge.gz') do |gz|
+ * gz.mtime = File.mtime(orig)
+ * gz.orig_name = orig
+ * gz.write IO.binread(orig)
+ * end
*
* NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
* GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter