module Chem::FormatWriter::MultiEntry(T)
Overview
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.
Direct including types
Defined in:
chem/format_writer.crConstructors
-
.new(io : IO, total_entries : Int32 | Nil = nil, sync_close : Bool = false)
Creates a new object from the given io.
Instance Method Summary
-
#<<(obj : T) : self
Writes obj to the
IO
. -
#multi? : Bool
Returns
true
if multiple entries or an indeterminate number of entries are to be written, elsefalse
.
Constructor Detail
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
.
Instance Method Detail
def <<(obj : T) : self
#
Writes obj to the IO
. It keeps count of the number of entries
written to the IO
.
def multi? : Bool
#
Returns true
if multiple entries or an indeterminate number of
entries are to be written, else false
.