Type:
Class

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

Following two example generate the same result.

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

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::GzipFile#close etc. Otherwise, GzipWriter will be not able to write the gzip footer and will generate a broken gzip file.

print

print(*args) Instance Public methods Same as

2015-06-14 18:45:44
<<

<<(p1) Instance Public methods Document-method: << Same as

2015-06-14 18:23:23
putc

putc(p1) Instance Public methods Same as

2015-06-14 18:52:13
orig_name=

orig_name=(p1) Instance Public methods Specify the original name (str)

2015-06-14 18:37:47
puts

puts(*args) Instance Public methods Same as

2015-06-14 18:53:32
pos

pos() Instance Public methods Total number of input bytes read so far.

2015-06-14 18:44:03
new

Zlib::GzipWriter.new(io, level = nil, strategy = nil, options = {}) Class Public methods

2015-06-14 18:11:12
tell

tell() Instance Public methods Total number of input bytes read so far.

2015-06-14 18:59:58
flush

flush(flush=nil) Instance Public methods Flushes all the internal buffers of

2015-06-14 18:29:52
write

write(p1) Instance Public methods Same as

2015-06-14 19:04:18