A write-only IO object to compress data in the zlib format.
Instances of this class wrap another IO object. When you write to this
instance, it compresses the data and writes it to the underlying IO.
NOTE: unless created with a block, close must be invoked after all
data has been written to a Zlib::Writer instance.
Constructors
new(io :
IO, level :
Int32 =
Zlib::DEFAULT_COMPRESSION, sync_close :
Bool = false, dict :
Bytes |
Nil = nil)
Creates a new writer to the given io.
Sourcenew(filename :
String, level =
Zlib::DEFAULT_COMPRESSION, dict :
Bytes |
Nil = nil)
Creates a new writer to the given filename.
SourceClass methods
open(io :
IO, level =
Zlib::DEFAULT_COMPRESSION, sync_close = false, dict :
Bytes |
Nil = nil, &)
Creates a new writer to the given io, yields it to the given block,
and closes it at the end.
Sourceopen(filename :
String, level =
Zlib::DEFAULT_COMPRESSION, dict :
Bytes |
Nil = nil, &)
Creates a new writer to the given filename, yields it to the given block,
and closes it at the end.
SourceInstance methods
close
Closes this writer. Must be invoked after all data has been written.
Sourceclosed?
Returns true if this writer is closed.
Sourceflush
Flushes data, forcing writing the zlib header if no
data has been written yet.
See IO#flush.
Sourceread(slice :
Bytes) :
NoReturn Always raises IO::Error because this is a write-only IO.
Sourcesync_close=(sync_close :
Bool)
Whether to close the enclosed IO when closing this writer.
Sourcesync_close?
Whether to close the enclosed IO when closing this writer.
Source