class

Compress::Deflate::Writer

Inherits IO / Reference / Object

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.

Constructors

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

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

Source

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 = nil, &)

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

Source

Instance methods

close

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

Source
closed?

Returns true if this IO is closed.

Source
flush

See IO#flush.

Source
inspect(io : IO) : Nil

Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
Source
read(slice : Bytes) : NoReturn

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

Source
sync_close=(sync_close : Bool)

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

Source
sync_close?

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

Source
write(slice : Bytes) : Nil

See IO#write.

Source