Class Zlib::GzipWriter
In: ext/zlib/zlib.c
Parent: Zlib::GzipFile

Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should be used with an instance of IO, or IO-like, object.

For example:

  Zlib::GzipWriter.open('hoge.gz') do |gz|
    gz.write 'jugemu jugemu gokou no surikire...'
  end

  File.open('hoge.gz', 'w') do |f|
    gz = Zlib::GzipWriter.new(f)
    gz.write 'jugemu jugemu gokou no surikire...'
    gz.close
  end

  # TODO: test these.  Are they equivalent?  Can GzipWriter.new take a
  # block?

NOTE: Due to the limitation of Ruby’s finalizer, you must explicitly close GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter will be not able to write the gzip footer and will generate a broken gzip file.

Methods

<<   comment=   flush   mtime=   new   open   orig_name=   pos   print   printf   putc   puts   tell   write  

Public Class methods

Creates a GzipWriter object associated with io. level and strategy should be the same as the arguments of Zlib::Deflate.new. The GzipWriter object writes gzipped data to io. At least, io must respond to the write method that behaves same as write method in IO class.

Opens a file specified by filename for writing gzip compressed data, and returns a GzipWriter object associated with that file. Further details of this method are found in Zlib::GzipWriter.new and Zlib::GzipWriter#wrap.

Public Instance methods

<<(p1)

Document-method: << Same as IO.

Same as IO.

Flushes all the internal buffers of the GzipWriter object. The meaning of flush is same as in Zlib::Deflate#deflate. Zlib::SYNC_FLUSH is used if flush is omitted. It is no use giving flush Zlib::NO_FLUSH.

print(...)

Document-method: print Same as IO.

Same as IO.

printf(...)

Document-method: printf Same as IO.

Same as IO.

Same as IO.

puts(...)

Document-method: puts Same as IO.

Same as IO.

Same as IO.

To view or add comments on this documentation, please go to the API wiki.

[Validate]