Class: Ilm::Chemistry::Compound

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#constituentsObject

Returns the value of attribute constituents.



11
12
13
# File 'lib/ilm/chemistry/compound.rb', line 11

def constituents
  @constituents
end

#formulaObject

Returns the value of attribute formula.



11
12
13
# File 'lib/ilm/chemistry/compound.rb', line 11

def formula
  @formula
end

#molar_massObject

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_massObject

Returns the value of attribute molecular_mass.



11
12
13
# File 'lib/ilm/chemistry/compound.rb', line 11

def molecular_mass
  @molecular_mass
end