Module: ChemistryParadise::Shared
Overview
ChemistryParadise::Shared
Constant Summary collapse
- ARRAY_TEST_THESE_MOLECULES =
#
ARRAY_TEST_THESE_MOLECULES
Test these molecules. Default values.
#
%w( NH3 NH4 MnO2 P2O5 H2O Pb3O4 H2SO4 C12H12N2 BaCO3 PbCrO4 Al2(SO4)3 Ca(OH)2 CH3COOH C12H22O11 )
Constants included from Constants
Constants::ELECTRON_NEGATIVITY_CHART, Constants::FILE_ATOMGEWICHTE, Constants::FILE_ELECTRON_NEGATIVITY_CHART, Constants::FILE_PERIODIC_TABLE_OF_THE_ELEMENTS, Constants::N, Constants::PLANK_CONSTANT, Constants::PROPER_FILLORDER, Constants::SPEED_OF_LIGHT
Class Method Summary collapse
-
.periodic_table? ⇒ Boolean
# === ChemistryParadise::Shared.periodic_table? ========================================================================= #.
Instance Method Summary collapse
-
#convert_parens(i) ⇒ Object
(also: #parse)
# === convert_parens ========================================================================= #.
-
#is_number?(i) ⇒ Boolean
# === is_number?.
-
#periodic_table? ⇒ Boolean
# === periodic_table? ========================================================================= #.
-
#return_range_for_this_period(this_period = 1) ⇒ Object
# === return_range_for_this_period.
-
#square(of) ⇒ Object
(also: #sqr)
# === square.
Methods included from Constants
Class Method Details
.periodic_table? ⇒ Boolean
#
ChemistryParadise::Shared.periodic_table?
#
80 81 82 |
# File 'lib/chemistry_paradise/shared.rb', line 80 def self.periodic_table? ::ChemistryParadise.periodic_table? end |
Instance Method Details
#convert_parens(i) ⇒ Object Also known as: parse
#
convert_parens
#
120 121 122 |
# File 'lib/chemistry_paradise/shared.rb', line 120 def convert_parens(i) ChemistryParadise.convert_parens(i) end |
#is_number?(i) ⇒ Boolean
#
is_number?
This method will return true if is a number, else false. For this it uses the .to_i method trick, which returns 0 for non-numbers.
#
53 54 55 56 |
# File 'lib/chemistry_paradise/shared.rb', line 53 def is_number?(i) result = (i.to_i.to_s == i) return result end |
#periodic_table? ⇒ Boolean
#
periodic_table?
#
73 74 75 |
# File 'lib/chemistry_paradise/shared.rb', line 73 def periodic_table? return Shared.periodic_table? end |
#return_range_for_this_period(this_period = 1) ⇒ Object
#
return_range_for_this_period
This method will tell us the legal range of elements for any given period.
The formula would be:
2+4n
For instance:
period 1 will return (1..2).
period 2 will return (3..8).
#
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/chemistry_paradise/shared.rb', line 98 def return_range_for_this_period(this_period = 1) case this_period when 1 (1..2) when 2 (3..10) when 3 (11..18) when 4 (19..36) when 5 (37..54) when 6 (55..86) when 7 (87..118) end end |
#square(of) ⇒ Object Also known as: sqr
#
square
Die Wurzel aus 2 ist 1.414
chem; square 2; sqr 3; sqr 4; sqr 5; sqr 6; sqr 7; sqr 8; sqr 9
#
66 67 68 |
# File 'lib/chemistry_paradise/shared.rb', line 66 def square(of) Math.sqrt of end |