Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more
Object
Zlib::GzipFile is an abstract class for handling a gzip formatted compressed file. The operations are defined in the subclasses, Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
GzipReader should be used by associating an IO, or IO-like, object.
::open (Zlib::GzipReader::open and Zlib::GzipWriter.open)
comment= (Zlib::GzipWriter#comment=)
eof? (Zlib::GzipReader#eof?)
lineno (Zlib::GzipReader#lineno)
lineno= (Zlib::GzipReader#lineno=)
mtime= (Zlib::GzipWriter#mtime=)
#orig_name (Zlib::GzipWriter#orig_name=)
path (when the underlying IO supports path)
(due to internal structure, documentation may appear under Zlib::GzipReader or Zlib::GzipWriter)
Creates a GzipFile object associated with
io
, and executes the block with the newly created GzipFile object, just like File.open. The GzipFile object will be closed automatically after
executing the block. If you want to keep the associated IO object opening,
you may call +Zlib::GzipFile#finish+ method in the block.
static VALUE rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass) { return gzfile_wrap(argc, argv, klass, 0); }
Closes the GzipFile object. This method calls close method of the associated IO object. Returns the associated IO object.
static VALUE rb_gzfile_close(VALUE obj) { struct gzfile *gz = get_gzfile(obj); VALUE io; io = gz->io; gzfile_close(gz, 1); return io; }
Same as IO#closed?
static VALUE rb_gzfile_closed_p(VALUE obj) { struct gzfile *gz; Data_Get_Struct(obj, struct gzfile, gz); return NIL_P(gz->io) ? Qtrue : Qfalse; }
Returns CRC value of the uncompressed data.
static VALUE rb_gzfile_crc(VALUE obj) { return rb_uint2inum(get_gzfile(obj)->crc); }
Returns compression level.
static VALUE rb_gzfile_level(VALUE obj) { return INT2FIX(get_gzfile(obj)->level); }
Returns last modification time recorded in the gzip file header.
static VALUE rb_gzfile_mtime(VALUE obj) { return rb_time_new(get_gzfile(obj)->mtime, (time_t)0); }
Returns original filename recorded in the gzip file header, or
nil
if original filename is not present.
static VALUE rb_gzfile_orig_name(VALUE obj) { VALUE str = get_gzfile(obj)->orig_name; if (!NIL_P(str)) { str = rb_str_dup(str); } OBJ_TAINT(str); /* for safe */ return str; }
Returns OS code number recorded in the gzip file header.
static VALUE rb_gzfile_os_code(VALUE obj) { return INT2FIX(get_gzfile(obj)->os_code); }
Same as IO#sync
static VALUE rb_gzfile_sync(VALUE obj) { return (get_gzfile(obj)->z.flags & GZFILE_FLAG_SYNC) ? Qtrue : Qfalse; }
Same as IO. If flag is true
, the associated IO object must
respond to the flush
method. While sync
mode is
true
, the compression ratio decreases sharply.
static VALUE rb_gzfile_set_sync(VALUE obj, VALUE mode) { struct gzfile *gz = get_gzfile(obj); if (RTEST(mode)) { gz->z.flags |= GZFILE_FLAG_SYNC; } else { gz->z.flags &= ~GZFILE_FLAG_SYNC; } return mode; }
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.
Returns comments recorded in the gzip file header, or nil if the comments is not present.