Class: Chemicalml::Model::Bond

Inherits:
Node
  • Object
show all
Defined in:
lib/chemicalml/model/bond.rb

Overview

A bond between two atoms. Endpoint references are string IDs matching Atom#id; the kind enum follows CML conventions.

Constant Summary collapse

KINDS =
%i[single double triple quadruple aromatic wedge hash
dative wavy].freeze
CML_ORDER =
{
  single: "S", double: "D", triple: "T", quadruple: "Q",
  aromatic: "A", wedge: "W", hash: "H", dative: "DG", wavy: "V"
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#==, #accept, #children, #hash, short_name

Constructor Details

#initialize(id: nil, atom_refs:, kind: :single) ⇒ Bond

Returns a new instance of Bond.



18
19
20
21
22
# File 'lib/chemicalml/model/bond.rb', line 18

def initialize(id: nil, atom_refs:, kind: :single)
  @id = id
  @atom_refs = atom_refs
  @kind = kind
end

Instance Attribute Details

#atom_refsObject

Returns the value of attribute atom_refs.



16
17
18
# File 'lib/chemicalml/model/bond.rb', line 16

def atom_refs
  @atom_refs
end

#idObject

Returns the value of attribute id.



16
17
18
# File 'lib/chemicalml/model/bond.rb', line 16

def id
  @id
end

#kindObject

Returns the value of attribute kind.



16
17
18
# File 'lib/chemicalml/model/bond.rb', line 16

def kind
  @kind
end

Instance Method Details

#cml_orderObject



28
29
30
# File 'lib/chemicalml/model/bond.rb', line 28

def cml_order
  CML_ORDER.fetch(kind, "S")
end

#value_attributesObject



24
25
26
# File 'lib/chemicalml/model/bond.rb', line 24

def value_attributes
  { id: id, atom_refs: atom_refs, kind: kind }
end