Class: Chemicalml::Model::Substance

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

Overview

A reaction participant. Wraps a Molecule with a role (e.g. :reactant, :product, :catalyst, :solvent).

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#==, #accept, #hash, short_name

Constructor Details

#initialize(molecule:, role: nil, title: nil) ⇒ Substance

Returns a new instance of Substance.



10
11
12
13
14
# File 'lib/chemicalml/model/substance.rb', line 10

def initialize(molecule:, role: nil, title: nil)
  @molecule = molecule
  @role = role
  @title = title
end

Instance Attribute Details

#moleculeObject

Returns the value of attribute molecule.



8
9
10
# File 'lib/chemicalml/model/substance.rb', line 8

def molecule
  @molecule
end

#roleObject

Returns the value of attribute role.



8
9
10
# File 'lib/chemicalml/model/substance.rb', line 8

def role
  @role
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/chemicalml/model/substance.rb', line 8

def title
  @title
end

Instance Method Details

#childrenObject



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

def children
  [molecule]
end

#value_attributesObject



20
21
22
# File 'lib/chemicalml/model/substance.rb', line 20

def value_attributes
  { molecule: molecule, role: role, title: title }
end