Class: Ilm::Chemistry::Reaction

Inherits:
Object
  • Object
show all
Defined in:
lib/ilm/chemistry/reaction.rb

Overview

This class has functionality for reaction Ex: check for balanced rxn, validity of a rxn

Constant Summary collapse

STATES =
{
  '(s)' => 'solid', '(l)' => 'liquid',
  '(g)' => 'gaseous', '(aq)' => 'aqueous',
  '' => ''
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Reaction

Returns a new instance of Reaction.



14
15
16
17
18
19
20
21
22
# File 'lib/ilm/chemistry/reaction.rb', line 14

def initialize(args)
  # rate_eqn should be of the form: 'r_{CaO} = k[CaO][CO2]'
  @equation = args[:equation]
  @species = build_species
  @is_valid = valid_rxn?
  participant_elements
  @balanced_eqn = balance_rxn
  @rate_equation = validify_rate_eqn args[:rate_equation]
end

Instance Attribute Details

#balanced_eqnObject

Returns the value of attribute balanced_eqn.



6
7
8
# File 'lib/ilm/chemistry/reaction.rb', line 6

def balanced_eqn
  @balanced_eqn
end

#equationObject

Returns the value of attribute equation.



6
7
8
# File 'lib/ilm/chemistry/reaction.rb', line 6

def equation
  @equation
end

#is_validObject

Returns the value of attribute is_valid.



6
7
8
# File 'lib/ilm/chemistry/reaction.rb', line 6

def is_valid
  @is_valid
end

#participantsObject

Returns the value of attribute participants.



6
7
8
# File 'lib/ilm/chemistry/reaction.rb', line 6

def participants
  @participants
end

#rate_equationObject

Returns the value of attribute rate_equation.



6
7
8
# File 'lib/ilm/chemistry/reaction.rb', line 6

def rate_equation
  @rate_equation
end

#speciesObject

Returns the value of attribute species.



6
7
8
# File 'lib/ilm/chemistry/reaction.rb', line 6

def species
  @species
end