class ChemistryParadise::ShowElectronConfiguration
Constants
- DEFAULT_INPUT
#¶ ↑
DEFAULT_INPUT
¶ ↑#¶ ↑
- MAIN_HASH
#¶ ↑
-
Periode: 1s
-
Periode: 2s 2p
-
Periode: 3s 3p
-
Periode: 4s 3d 4p
-
Periode: 5s 4d 5p
-
Periode: 6s 4f 5d 6p
-
Periode: 7s 5f 6d
#¶ ↑
The following hash was taken from:
http://en.wikipedia.org/wiki/Electron_configuration#Other_exceptions_to_Madelung.27s_rule
and from:
http://en.wikipedia.org/wiki/Electron_configurations_of_the_elements_%28data_page%29
#¶ ↑
-
- NEBENQUANTENZAHL
#¶ ↑
NEBENQUANTENZAHL
¶ ↑#¶ ↑
- PERIODIC_TABLE
#¶ ↑
PERIODIC_TABLE
¶ ↑#¶ ↑
Public Class Methods
Public Instance Methods
check_for_inclusion()
click to toggle source
#¶ ↑
check_for_inclusion
¶ ↑
#¶ ↑
# File lib/chemistry_paradise/show_electron_configuration.rb, line 193 def check_for_inclusion if periodic_table?.has_key? @input set_n_electrons periodic_table?[@input] e 'Found element '+sfancy(@input)+'. '+ 'It has '+simp(@n_electrons.to_s)+' electrons.' display_electron_configuration(@n_electrons) else e "Did not find element called `#{sfancy(@input)}`." end end
default_colour()
click to toggle source
display_electron_configuration(i = @n_electrons)
click to toggle source
#¶ ↑
display_electron_configuration
¶ ↑
Show the specific electron configuration.
For instance:
1s2 2s2 2p6 3s2 3p4
#¶ ↑
# File lib/chemistry_paradise/show_electron_configuration.rb, line 212 def display_electron_configuration(i = @n_electrons) # ======================================================================= # # Notify the user of invalid input. # ======================================================================= # unless main_hash?.has_key? i e 'Note that the electron at position '+i.to_s+ ' is not registered.' end set_main_string MAIN_HASH[i] # ======================================================================= # # Output it next: # ======================================================================= # e yellow(@_) end
main_hash?()
click to toggle source
periodic_table?()
click to toggle source
reset()
click to toggle source
run()
click to toggle source
set_input(i = N)
click to toggle source
#¶ ↑
set_input
¶ ↑
#¶ ↑
# File lib/chemistry_paradise/show_electron_configuration.rb, line 149 def set_input(i = N) i = i.first if i.is_a? Array i = DEFAULT_INPUT if i.nil? i = i.to_s.dup.delete('/') # We don't need '/' characters. i = periodic_table?.invert[i.to_i] if i =~ /^\d+$/ # ======================================================================= # # Since as of June 2016, we will upcase the first character. # ======================================================================= # i = i.dup if i.frozen? i[0,1] = i[0,1].upcase @input = i end
set_main_string(i)
click to toggle source