Skip to content

class Compress::Deflate::Writer
inherits IO

A write-only IO object to compress data in the DEFLATE 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 Flate::Writer instance.

Class methods

.open(io : IO, level : Int32 = Compress::Deflate::DEFAULT_COMPRESSION, strategy : Compress::Deflate::Strategy = Compress::Deflate::Strategy::DEFAULT, sync_close : Bool = false, dict : Bytes? = nil

Creates a new writer for the given io, yields it to the given block, and closes it at its end.

View source

.new(output : IO, level : Int32 = Compress::Deflate::DEFAULT_COMPRESSION, strategy : Compress::Deflate::Strategy = Compress::Deflate::Strategy::DEFAULT, sync_close : Bool = false, dict : Bytes? = nil)

Creates an instance of Flate::Writer. close must be invoked after all data has written.

View source

Methods

#close

Closes this writer. Must be invoked after all data has been written.

View source

#closed? : Bool

Returns true if this IO is closed.

View source

#flush

See IO#flush.

View source

#read(slice : Bytes)

Always raises IO::Error because this is a write-only IO.

View source

#sync_close=(sync_close : Bool)

If #sync_close? is true, closing this IO will close the underlying IO.

View source

#sync_close? : Bool

If #sync_close? is true, closing this IO will close the underlying IO.

View source

#write(slice : Bytes) : Nil

See IO#write.

View source