module Indexable(T)

Overview

Gather, check and annotate types registering a format

Included Modules

Direct including types

Defined in:

lib/views/src/views/indexable_view.cr
chem/core_ext/indexable.cr
chem/register_format.cr

Instance Method Summary

Instance methods inherited from module Enumerable(T)

===(atom : Chem::Atom) : Bool
===(chain : Chem::Chain) : Bool
===(residue : Chem::Residue) : Bool
===
, average(weights : Indexable(Number))
average(weights : Indexable(Number), & : T -> _)
average
, find(pattern, if_none default = nil) find, find!(pattern) find!, mean
mean(& : T -> _)
mean
, to_dcd(io : IO, title : String | Nil = nil) : Nil
to_dcd(title : String | Nil = nil) : String
to_dcd(path : Path | String, title : String | Nil = nil) : Nil
to_dcd
, to_mol2(io : IO) : Nil
to_mol2(path : Path | String) : Nil
to_mol2 : String
to_mol2
, to_pdb(io : IO, conect conect_options : PDB::ConectOptions = PDB::ConectOptions.flags(Het, Disulfide), renumber : Bool = true, ter_on_fragment : Bool = false) : Nil
to_pdb(conect conect_options : PDB::ConectOptions = PDB::ConectOptions.flags(Het, Disulfide), renumber : Bool = true, ter_on_fragment : Bool = false) : String
to_pdb(path : Path | String, conect conect_options : PDB::ConectOptions = PDB::ConectOptions.flags(Het, Disulfide), renumber : Bool = true, ter_on_fragment : Bool = false) : Nil
to_pdb
, to_sdf(io : IO, variant : Mol::Variant = :v2000) : Nil
to_sdf(path : Path | String, variant : Mol::Variant = :v2000) : Nil
to_sdf(variant : Mol::Variant = :v2000) : String
to_sdf
, to_xyz(io : IO, extended : Bool = false, fields : Array(String) = [] of String) : Nil
to_xyz(extended : Bool = false, fields : Array(String) = [] of String) : String
to_xyz(path : Path | String, extended : Bool = false, fields : Array(String) = [] of String) : Nil
to_xyz

Instance Method Detail

def [](idxs : Tuple) : Tuple #

Returns a tuple with the elements at the given indexes. Raises IndexError is any index is out of bounds.

arr = (0..9).map(&.**(2)) # => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
arr[{2, 5, 9}]            # => {4, 25, 81}
arr[{2, 15, 9}]           # raises IndexError

[View source]
def [](idxs : Enumerable(Int)) : Array(T) #

Returns an array with the elements at the given indexes. Raises IndexError is any index is out of bounds.

arr = (0..9).map(&.**(2)) # => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
arr[[2, 5, 9]]            # => [4, 25, 81]
arr[[2, 15, 9]]           # raises IndexError

[View source]
def [](*idxs : Int) : Tuple #

Returns a tuple with the elements at the given indexes. Raises IndexError is any index is out of bounds.

arr = (0..9).map(&.**(2)) # => [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
arr[2, 5, 9]              # => {4, 25, 81}
arr[2, 15, 9]             # raises IndexError

[View source]
def sentence(io : IO, separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ", & : T, IO -> ) : Nil #

Prints the elements in the collection as a sentence to io. How each element is printed is controlled by the given block.

The output depends on the number of elements in the collection:

  • If there are three or more elements, all but the tail element in the collection are joined by separator, and the tail element is joined by tail_separator.
  • If there are two elements, these are joined by pair_separator.
  • If there is one element, it is printed to io without any separator.
  • If the collection is empty, nothing is printed.
[1, 2, 3].sentence(STDOUT, "-", tail_separator: "-or-") { |e, io| io << "(#{e})" }

Prints:

(1)-(2)-or-(3)

[View source]
def sentence(io : IO, separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ") : Nil #

Prints the elements in the collection as a sentence to io.

The output depends on the number of elements in the collection:

  • If there are three or more elements, all but the tail element in the collection are joined by separator, and the tail element is joined by tail_separator.
  • If there are two elements, these are joined by pair_separator.
  • If there is one element, it is printed to io without any separator.
  • If the collection is empty, nothing is printed.
[1, 2, 3].sentence(STDOUT, "-", tail_separator: "-or-")

Prints:

1-2-or-3

[View source]
def sentence(separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ", & : T -> ) : String #

Returns a String by concatenating the elements in the collection as a sentence. How each element is printed is controlled by the given block.

The string representation depends on the number of elements in the collection:

  • If there are three or more elements, all but the tail element in the collection are joined by separator, and the tail element is joined by tail_separator.
  • If there are two elements, these are joined by pair_separator.
  • If there is one element, it is returned as is.
  • If the collection is empty, an empty string is returned.
[1, 2, 3].sentence { |e| "(#{e})" }                              # => "(1), (2), and (3)"
[1, 2, 3].sentence("-", tail_separator: "-or-") { |e| "(#{e})" } # => "(1)-(2)-or-(3)"

[View source]
def sentence(separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ") : String #

Returns a String by concatenating the elements in the collection as a sentence.

The string representation depends on the number of elements in the collection:

  • If there are three or more elements, all but the tail element in the collection are joined by separator, and the tail element is joined by tail_separator.
  • If there are two elements, these are joined by pair_separator.
  • If there is one element, it is returned as is.
  • If the collection is empty, an empty string is returned.
([] of Int32).sentence                          # => ""
[1].sentence                                    # => "1"
[1, 2].sentence                                 # => "1 and 2"
[1, 2].sentence(pair_separator: "-or-")         # => "1-or-2"
[1, 2, 3].sentence                              # => "1, 2, and 3"
[1, 2, 3].sentence("-", tail_separator: "-or-") # => "1-2-or-3"

[View source]
def to_dcd(io : IO, title : String | Nil = nil) : Nil #

[View source]
def to_dcd(title : String | Nil = nil) : String #

[View source]
def to_dcd(path : Path | String, title : String | Nil = nil) : Nil #

[View source]