module

Chem::FormatWriter::MultiEntry(T)

The MultiEntry mixin provides an interface for writing in a file format that can hold a variable number of objects.

It holds the total number of entries (#total_entries) and reimplements the << operator to track how many of them has been written so far.

Constructors

new(io : IO, total_entries : Int32 | Nil = nil, sync_close : Bool = false)

Creates a new object from the given io. If the number of entries to be written is known, pass total_entries, otherwise set it to nil.

Source

Instance methods

<<(obj : T) : self

Writes obj to the IO. It keeps count of the number of entries written to the IO.

Source
multi?

Returns true if multiple entries or an indeterminate number of entries are to be written, else false.

Source