module Chem::FormatReader::Indexable(T)
Overview
Declares a common interface for indexed reading of a finite number of objects encoded in a file format.
Including types must implement methods to track and set the current object in the IO.
Included Modules
Direct including types
Defined in:
chem/format_reader.crInstance Method Summary
-
#entry_index : Int32
Returns the index of the current entry.
-
#n_entries : Int32
Returns the number of entries in the IO.
-
#next_entry : T | Nil
Returns the next entry in the IO, or
nil
if there are no more entries. -
#read_entry(index : Int) : T
Returns the entry at the given index.
-
#skip_entry : Nil
Discards the next entry in the IO without fully parsing it.
-
#skip_to_entry(index : Int) : Nil
Discards the entries (without parsing) up until the given index.
Instance methods inherited from module Chem::FormatReader::MultiEntry(T)
each(indexes : Enumerable(Int), & : T -> )each(& : T -> ) : Nil each, next_entry : T | Nil next_entry, read_entry : T read_entry, skip_entry : Nil skip_entry
Instance Method Detail
def read_entry(index : Int) : T
#
Returns the entry at the given index. Raises IndexError
if the
index is invalid.
def skip_entry : Nil
#
Description copied from module Chem::FormatReader::MultiEntry(T)
Discards the next entry in the IO without fully parsing it.
abstract
def skip_to_entry(index : Int) : Nil
#
Discards the entries (without parsing) up until the given index.
Raises IndexError
if the index is invalid.