Class: ParEnumerable
Parent: Object
Includes: Enumerable

Description

Overview

The class ParEnumerable provides array-like interfaces (i.e. methods of the module Enumerable) for collective data in Parameter. ParEnumerable does not implement initialize nor new methods. Instead, an instance of ParEnumerable is created by methods of Parameter, i.e. Parameter#angles, Parameter#bonds, Parameter#dihedrals, Parameter#elements, Parameter#impropers, Parameter#vdw_cutoffs, Parameter#vdw_pairs, and Parameter#vdws. These methods give ParEnumerable objects that are tied to the Parameter object and have a designated type (angle, atom, etc.)

As described in Parameter, the parameters can either be global or local. The global parameters can be seen from anywhere in the application, whereas the local parameters are specific to a particular Molecule. ParEnumerable objects are derived from Parameter, so that they also distinguish between global and local parameters. That is, the ParEnumerable object derived from the local Parameter object does not touch the global parameter, and vice versa. The only exception is ParEnumerable#lookup method of the local ParEnumerable object, which may look for the global parameters as directed by the options (actually it does so by default).

The index operator ParEnumerable#[] returns a ParameterRef object, which gives an access to the index-th entry of the given type in the associated Parameter. The assignment operator ([]=) is not implemented, because any modification should be performed through methods of ParameterRef. On the other hand, ParEnumerable implements insert and delete methods, which allow creating and removing parameters. These methods work for the local parameters only; the global parameters cannot be created or removed by use of these methods.

Public Instance methods

self[idx] → ParameterRef

Call the accessor of the Parameter object from which this ParEnumerable object is derived from. Thus, if self is "bond" type, self[idx] is equivalent to p.bond(idx), where p is the parent Parameter object of self.

See Also: Parameter#bond, Parameter#angle, Parameter#dihedral, Parameter#improper, Parameter#vdw, Parameter#vdw_pair, Parameter#vdw_cutoff, Parameter#element.

delete(Integer)
delete(IntGroup)

Delete the parameter(s) specified by the argument. Throws an exception if self is associated to the global parameter.

each {|pref| ...}

Call the block for each parameter, passing a ParameterRef object as a block argument. Note that the same ParameterRef object is passed for every iteration. For example, the following code snippet does not work as expected, because all entries in ary will point to the last entry.

p = Molecule.current.parameter  #  Get the Parameter object
ary = []
p.bonds.each { |bp|
  ary.push(bp)   #  Push the ParameterRef for each entry, but...
}
ary.each { |bp|
  p bp           #  The same (last) instance is printed for all entries
}
insert(idx = nil, pref = nil) → ParameterRef

Insert a new parameter at the specified position (if idx is nil, then at the end). If a ParameterRef is given, then the content of the parameter is copied to the new parameter, and the parameter is marked as molecule-local. Otherwise, the new parameter is marked as undefined. Throws an exception if self is associated to the global parameter.

length → Integer

Returns the number of parameters included in this enumerable.

lookup(atom_types, options, ...) → ParameterRef
lookup(atom_type_string, options, ...) → ParameterRef

Call Parameter#lookup with the parameter type as the first argument and the given atom types and options as the remaining arguments.

par_type → String

Get the parameter type, like "bond", "angle", etc.

reverse_each {|pref| ...}

Call the block for each parameter in the reverse order, passing a ParameterRef object as a block argument. Note that the same ParameterRef object is passed for every iteration. See the note for ParEnumerable#each.