- Inheritance
- < Zlib::GzipFile < Object
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
Class
| Visibility | Signature |
|---|---|
| public | new (...) |
| public | open (...) |
Instance
| Visibility | Signature |
|---|---|
| public | << (p1) |
| public | comment= (p1) |
| public | flush (...) |
| public | mtime= (p1) |
| public | orig_name= (p1) |
| public | pos () |
| public | print (...) |
| public | printf (...) |
| public | putc (p1) |
| public | puts (...) |
| public | tell () |
| public | write (p1) |
Class Method Detail
Zlib::GzipWriter.new(io, level, strategy)
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.
Zlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
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.
Instance Method Detail
<<(p1)
comment=(p1)
???
flush(flush=nil)
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.
mtime=(p1)
???
orig_name=(p1)
???
pos()
???
print(...)
printf(...)
putc(p1)
Same as IO.
puts(...)
tell()
???
write(p1)
Same as IO.