Class: Ilm::Chemistry::Compound
- Inherits:
-
Object
- Object
- Ilm::Chemistry::Compound
- Defined in:
- lib/ilm/chemistry/compound.rb
Overview
This class has functionality for compounds Ex: constituent elements, molecular mass, etc
Constant Summary collapse
- COMPOUND_REGEXP =
/[A-Z][a-z]{0,2}\d*|\((?:[^()]*(?:\(.*\))?[^()]*)+\)\d*/
Instance Attribute Summary collapse
-
#constituents ⇒ Object
Returns the value of attribute constituents.
-
#formula ⇒ Object
Returns the value of attribute formula.
-
#molar_mass ⇒ Object
Returns the value of attribute molar_mass.
-
#molecular_mass ⇒ Object
Returns the value of attribute molecular_mass.
Instance Method Summary collapse
-
#initialize(arg) ⇒ Compound
constructor
A new instance of Compound.
Constructor Details
#initialize(arg) ⇒ Compound
Returns a new instance of Compound.
13 14 15 16 17 |
# File 'lib/ilm/chemistry/compound.rb', line 13 def initialize(arg) @formula = arg build_constituents calculate_mass end |
Instance Attribute Details
#constituents ⇒ Object
Returns the value of attribute constituents.
11 12 13 |
# File 'lib/ilm/chemistry/compound.rb', line 11 def constituents @constituents end |
#formula ⇒ Object
Returns the value of attribute formula.
11 12 13 |
# File 'lib/ilm/chemistry/compound.rb', line 11 def formula @formula end |
#molar_mass ⇒ Object
Returns the value of attribute molar_mass.
11 12 13 |
# File 'lib/ilm/chemistry/compound.rb', line 11 def molar_mass @molar_mass end |
#molecular_mass ⇒ Object
Returns the value of attribute molecular_mass.
11 12 13 |
# File 'lib/ilm/chemistry/compound.rb', line 11 def molecular_mass @molecular_mass end |