Class: RubyChem::Valence
- Inherits:
-
Object
- Object
- RubyChem::Valence
- Defined in:
- lib/rubychem/valence.rb
Constant Summary collapse
- Fillorder =
["1s","2s","2p","3s","3p","4s","3d","4p","5s","4d","5p","6s","4f","5d","6p","7s","5f","6d","7p"]
Instance Attribute Summary collapse
-
#calc_valence ⇒ Object
Returns the value of attribute calc_valence.
Instance Method Summary collapse
- #calculate_electronic_config ⇒ Object
-
#initialize(k) ⇒ Valence
constructor
A new instance of Valence.
Constructor Details
#initialize(k) ⇒ Valence
Returns a new instance of Valence.
6 7 8 9 10 11 12 |
# File 'lib/rubychem/valence.rb', line 6 def initialize(k) @mass = k determine_valence(@mass) @calc_valence = Hash.new @calc_valence = calculate_electronic_config identify_valence_electrons end |
Instance Attribute Details
#calc_valence ⇒ Object
Returns the value of attribute calc_valence.
4 5 6 |
# File 'lib/rubychem/valence.rb', line 4 def calc_valence @calc_valence end |
Instance Method Details
#calculate_electronic_config ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rubychem/valence.rb', line 14 def calculate_electronic_config @shell_location = 0 1.upto(100) do |x| until @v <= 0 shell_electrons = determine_valence_electrons_in_shell(@shell_location) @before_subtract = @v @v -= shell_electrons @calc_valence[Fillorder[@shell_location]] = shell_electrons move_on(@v) end end @calc_valence end |