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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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.


[View source]

Instance Method Detail

def <<(obj : T) : self #

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


[View source]
def multi? : Bool #

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


[View source]