chemistry_paradise 1.1.26
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chemistry_paradise might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/README.md +419 -0
- data/bin/chemistry_paradise +7 -0
- data/chemistry_paradise.gemspec +46 -0
- data/doc/BUGS.md +16 -0
- data/doc/README.gen +391 -0
- data/doc/todo/TODO.md +26 -0
- data/lib/chemistry_paradise/base/base.rb +101 -0
- data/lib/chemistry_paradise/base/colours.rb +65 -0
- data/lib/chemistry_paradise/commandline/help.rb +40 -0
- data/lib/chemistry_paradise/commandline/menu.rb +88 -0
- data/lib/chemistry_paradise/commandline/parse_commandline.rb +94 -0
- data/lib/chemistry_paradise/constants/constants.rb +52 -0
- data/lib/chemistry_paradise/constants/file_constants.rb +33 -0
- data/lib/chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb +157 -0
- data/lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb +143 -0
- data/lib/chemistry_paradise/converters/fahrenheit_to_celsius.rb +132 -0
- data/lib/chemistry_paradise/converters/shared.rb +15 -0
- data/lib/chemistry_paradise/gui/gtk3/calculate_molecular_weight/calculate_molecular_weight.rb +34 -0
- data/lib/chemistry_paradise/gui/gtk3/show_periodic_table/show_periodic_table.rb +34 -0
- data/lib/chemistry_paradise/gui/gtk3/temperature_converter/temperature_converter.rb +249 -0
- data/lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb +171 -0
- data/lib/chemistry_paradise/gui/shared_code/show_periodic_table/show_periodic_table_module.rb +318 -0
- data/lib/chemistry_paradise/images/show_periodic_table.png +0 -0
- data/lib/chemistry_paradise/interactive_chemistry_shell.rb +246 -0
- data/lib/chemistry_paradise/project/project.rb +24 -0
- data/lib/chemistry_paradise/requires/common_external_requires.rb +17 -0
- data/lib/chemistry_paradise/requires/require_the_project.rb +19 -0
- data/lib/chemistry_paradise/shared.rb +130 -0
- data/lib/chemistry_paradise/show_electron_configuration.rb +250 -0
- data/lib/chemistry_paradise/show_element.rb +145 -0
- data/lib/chemistry_paradise/sinatra/sinatra.rb +131 -0
- data/lib/chemistry_paradise/split_molecule_names.rb +228 -0
- data/lib/chemistry_paradise/toplevel_methods/atomgewichte.rb +31 -0
- data/lib/chemistry_paradise/toplevel_methods/convert_parens.rb +64 -0
- data/lib/chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb +24 -0
- data/lib/chemistry_paradise/toplevel_methods/e.rb +16 -0
- data/lib/chemistry_paradise/toplevel_methods/kelvin.rb +34 -0
- data/lib/chemistry_paradise/toplevel_methods/language.rb +50 -0
- data/lib/chemistry_paradise/toplevel_methods/misc.rb +128 -0
- data/lib/chemistry_paradise/toplevel_methods/periodic_table.rb +16 -0
- data/lib/chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb +63 -0
- data/lib/chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb +26 -0
- data/lib/chemistry_paradise/utility_scripts/calculate_atomic_mass.rb +559 -0
- data/lib/chemistry_paradise/utility_scripts/combustion_analysis.rb +207 -0
- data/lib/chemistry_paradise/utility_scripts/electron_negativity_chart.rb +78 -0
- data/lib/chemistry_paradise/utility_scripts/equalize_chemical_formula.rb +84 -0
- data/lib/chemistry_paradise/utility_scripts/equation_solver.rb +130 -0
- data/lib/chemistry_paradise/utility_scripts/orbitals.rb +70 -0
- data/lib/chemistry_paradise/utility_scripts/show_electron_negativity_of_this_element.rb +103 -0
- data/lib/chemistry_paradise/verbose_chemical_calculation.rb +21 -0
- data/lib/chemistry_paradise/version/version.rb +19 -0
- data/lib/chemistry_paradise/www/chemistry/chemistry.cgi +7 -0
- data/lib/chemistry_paradise/www/chemistry/chemistry.rb +1526 -0
- data/lib/chemistry_paradise/www/chemistry/chemistry.sinatra +56 -0
- data/lib/chemistry_paradise/www/organic_chemistry/organic_chemistry.md +16 -0
- data/lib/chemistry_paradise/yaml/atomgewichte.yml +113 -0
- data/lib/chemistry_paradise/yaml/colours_for_the_elements.yml +13 -0
- data/lib/chemistry_paradise/yaml/dichte.yml +21 -0
- data/lib/chemistry_paradise/yaml/electron_negativity_chart.yml +111 -0
- data/lib/chemistry_paradise/yaml/molecular_formula_of_different_molecules.yml +13 -0
- data/lib/chemistry_paradise/yaml/periodic_table_of_the_elements.yml +125 -0
- data/lib/chemistry_paradise.rb +1 -0
- data/test/testing_chemistry_paradise.rb +49 -0
- metadata +155 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === ChemistryParadise::ParseCommandline
|
6
|
+
# =========================================================================== #
|
7
|
+
# require 'chemistry_paradise/commandline/menu.rb'
|
8
|
+
# =========================================================================== #
|
9
|
+
require 'chemistry_paradise/base/base.rb'
|
10
|
+
|
11
|
+
module ChemistryParadise
|
12
|
+
|
13
|
+
class ParseCommandline < ::ChemistryParadise::Base # === ChemistryParadise::ParseCommandline
|
14
|
+
|
15
|
+
require 'chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb'
|
16
|
+
require 'chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb'
|
17
|
+
require 'chemistry_paradise/utility_scripts/show_electron_negativity_of_this_element.rb'
|
18
|
+
|
19
|
+
# ========================================================================= #
|
20
|
+
# === menu (menu tag)
|
21
|
+
# ========================================================================= #
|
22
|
+
def menu(
|
23
|
+
i = @commandline
|
24
|
+
)
|
25
|
+
if i.is_a? Array
|
26
|
+
i.each {|entry| menu(entry) }
|
27
|
+
else
|
28
|
+
case i
|
29
|
+
# ===================================================================== #
|
30
|
+
# === chemistry_paradise --gtk-calculate-molecular-weight
|
31
|
+
# ===================================================================== #
|
32
|
+
when /^-?-?gtk(_|-)?calculate(_|-)?molecular(_|-)?weight$/i
|
33
|
+
require 'chemistry_paradise/gui/gtk3/calculate_molecular_weight/calculate_molecular_weight.rb'
|
34
|
+
ChemistryParadise::GUI::Gtk::CalculateMolecularWeight.run
|
35
|
+
exit
|
36
|
+
# ===================================================================== #
|
37
|
+
# === chemistry_paradise --periodic-table
|
38
|
+
# ===================================================================== #
|
39
|
+
when /^-?-?periodic(_|-)?table$/i
|
40
|
+
show_the_periodic_table
|
41
|
+
exit
|
42
|
+
# ===================================================================== #
|
43
|
+
# === chemistry_paradise --electronegativity-of=F/Fe
|
44
|
+
# ===================================================================== #
|
45
|
+
when /-?-?electronegativity(_|-)?of=(.+)/
|
46
|
+
these_elements = $2.to_s.dup.strip
|
47
|
+
if these_elements.include? '/'
|
48
|
+
these_elements = these_elements.split('/')
|
49
|
+
end
|
50
|
+
ChemistryParadise::ShowElectronNegativityOfThisElement.new(these_elements)
|
51
|
+
# ===================================================================== #
|
52
|
+
# === chemistry_paradise show_electron_negativity_chart
|
53
|
+
# ===================================================================== #
|
54
|
+
when /show(_|-)?electron(_|-)?negativity(_|-)?chart/
|
55
|
+
show_electron_negativity_chart
|
56
|
+
# ===================================================================== #
|
57
|
+
# === chemistry_paradise test_which_molecules?
|
58
|
+
# ===================================================================== #
|
59
|
+
when /test(_|-)?which(_|-)?molecules\??/
|
60
|
+
pp ARRAY_TEST_THESE_MOLECULES
|
61
|
+
# ===================================================================== #
|
62
|
+
# === chemistry_paradise --molmassen?
|
63
|
+
# ===================================================================== #
|
64
|
+
when /molmassen\??/,
|
65
|
+
/display(_|-)?molmassen(_|-)?file/,
|
66
|
+
/display(_|-)?where(_|-)?the(_|-)?molmasses(_|-)?are(_|-)?kept/
|
67
|
+
::ChemistryParadise.display_where_the_molmasses_are_kept
|
68
|
+
# ===================================================================== #
|
69
|
+
# === chemistry_paradise --help
|
70
|
+
# ===================================================================== #
|
71
|
+
when /^-?-?help/
|
72
|
+
show_help
|
73
|
+
else
|
74
|
+
if i.start_with?('/') and i.end_with?('/')
|
75
|
+
# ================================================================= #
|
76
|
+
# Assume this to be a pseudo-regex.
|
77
|
+
# ================================================================= #
|
78
|
+
search_for_this_element = i.delete('/').capitalize
|
79
|
+
_ = ChemistryParadise.return_element_symbol_from_this_german_name(search_for_this_element)
|
80
|
+
if _
|
81
|
+
e simp(search_for_this_element)+' corresponds to '+sfancy(_)+'.'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end; alias check_against_menu menu # === check_against_menu
|
87
|
+
|
88
|
+
end; end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === ChemistryParadise::ParseCommandline
|
6
|
+
#
|
7
|
+
# Use this class in order to parse the commandline.
|
8
|
+
# =========================================================================== #
|
9
|
+
# require 'chemistry_paradise/commandline/parse_commandline.rb'
|
10
|
+
# =========================================================================== #
|
11
|
+
require 'chemistry_paradise/base/base.rb'
|
12
|
+
require 'chemistry_paradise/commandline/menu.rb'
|
13
|
+
require 'chemistry_paradise/commandline/help.rb'
|
14
|
+
|
15
|
+
module ChemistryParadise
|
16
|
+
|
17
|
+
class ParseCommandline < ::ChemistryParadise::Base # === ChemistryParadise::ParseCommandline
|
18
|
+
|
19
|
+
# ========================================================================= #
|
20
|
+
# === initialize
|
21
|
+
# ========================================================================= #
|
22
|
+
def initialize(
|
23
|
+
optional_input = ARGV,
|
24
|
+
run_already = true
|
25
|
+
)
|
26
|
+
set_commandline(optional_input)
|
27
|
+
reset
|
28
|
+
run if run_already
|
29
|
+
end
|
30
|
+
|
31
|
+
# ========================================================================= #
|
32
|
+
# === reset
|
33
|
+
# ========================================================================= #
|
34
|
+
def reset
|
35
|
+
super()
|
36
|
+
end
|
37
|
+
|
38
|
+
# ========================================================================= #
|
39
|
+
# === show_the_periodic_table
|
40
|
+
# ========================================================================= #
|
41
|
+
def show_the_periodic_table
|
42
|
+
_ = ::ChemistryParadise.periodic_table?
|
43
|
+
if File.exist? _
|
44
|
+
YAML.load_file(_).each_pair {|key, value|
|
45
|
+
e ' '+(key.to_s+ ':').ljust(3)+' '+value.to_s.rjust(2)
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# ========================================================================= #
|
51
|
+
# === set_commandline
|
52
|
+
# ========================================================================= #
|
53
|
+
def set_commandline(i)
|
54
|
+
i = [i] unless i.is_a? Array
|
55
|
+
@commandline = i
|
56
|
+
end
|
57
|
+
|
58
|
+
# ========================================================================= #
|
59
|
+
# === run
|
60
|
+
# ========================================================================= #
|
61
|
+
def run
|
62
|
+
menu
|
63
|
+
end
|
64
|
+
|
65
|
+
# ========================================================================= #
|
66
|
+
# === berechne_atomgewicht
|
67
|
+
# ========================================================================= #
|
68
|
+
def berechne_atomgewicht(i)
|
69
|
+
pp i
|
70
|
+
if i.is_a? Array
|
71
|
+
i.flatten.each {|entry|
|
72
|
+
berechne_atomgewicht(i)
|
73
|
+
}
|
74
|
+
else
|
75
|
+
if i == :test_default_molecules
|
76
|
+
i = ARRAY_TEST_THESE_MOLECULES
|
77
|
+
end
|
78
|
+
if i.is_a? Array
|
79
|
+
berechne_atomgewicht(i)
|
80
|
+
else
|
81
|
+
e sprintf(
|
82
|
+
'The mass number of %-4s is %3s',
|
83
|
+
i,
|
84
|
+
ChemistryParadise::CalculateAtomicMass.new(i).result.to_s
|
85
|
+
)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end; end
|
91
|
+
|
92
|
+
if __FILE__ == $PROGRAM_NAME
|
93
|
+
ChemistryParadise::ParseCommandline.new(ARGV)
|
94
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/constants/constants.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'yaml'
|
8
|
+
require 'chemistry_paradise/constants/file_constants.rb'
|
9
|
+
|
10
|
+
module ChemistryParadise
|
11
|
+
|
12
|
+
module Constants # include ChemistryParadise::Constants
|
13
|
+
|
14
|
+
# ========================================================================= #
|
15
|
+
# === N
|
16
|
+
# ========================================================================= #
|
17
|
+
N = "\n"
|
18
|
+
|
19
|
+
# ========================================================================= #
|
20
|
+
# === ELECTRON_NEGATIVITY_CHART
|
21
|
+
# ========================================================================= #
|
22
|
+
if File.exist? FILE_ELECTRON_NEGATIVITY_CHART
|
23
|
+
ELECTRON_NEGATIVITY_CHART = YAML.load_file(FILE_ELECTRON_NEGATIVITY_CHART)
|
24
|
+
else
|
25
|
+
ELECTRON_NEGATIVITY_CHART = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
# ========================================================================= #
|
29
|
+
# === electron_negativity_chart?
|
30
|
+
# ========================================================================= #
|
31
|
+
def electron_negativity_chart?
|
32
|
+
ELECTRON_NEGATIVITY_CHART
|
33
|
+
end
|
34
|
+
|
35
|
+
# ========================================================================= #
|
36
|
+
# === SPEED_OF_LIGHT
|
37
|
+
#
|
38
|
+
# The speed of light, in m / sec.
|
39
|
+
#
|
40
|
+
# You can refer to this constant in your ruby scripts too:
|
41
|
+
# c = ChemistryParadise::Constants::SPEED_OF_LIGHT
|
42
|
+
# ========================================================================= #
|
43
|
+
SPEED_OF_LIGHT = 299_792_458
|
44
|
+
|
45
|
+
# ========================================================================= #
|
46
|
+
# === PLANK_CONSTANT
|
47
|
+
#
|
48
|
+
# h = ChemistryParadise::Constants::PLANK_CONSTANT
|
49
|
+
# ========================================================================= #
|
50
|
+
PLANK_CONSTANT = 6.62607004 * (10 ** -34)
|
51
|
+
|
52
|
+
end; end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/constants/file_constants.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
require 'chemistry_paradise/project/project.rb'
|
8
|
+
|
9
|
+
module ChemistryParadise
|
10
|
+
|
11
|
+
module Constants # === ChemistryParadise::Constants
|
12
|
+
|
13
|
+
# ========================================================================= #
|
14
|
+
# === FILE_ELECTRON_NEGATIVITY_CHART
|
15
|
+
#
|
16
|
+
# bl $RUBY_SRC/chemistry_paradise/lib/chemistry_paradise/yaml/electron_negativity_chart.yml
|
17
|
+
# ========================================================================= #
|
18
|
+
FILE_ELECTRON_NEGATIVITY_CHART =
|
19
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/electron_negativity_chart.yml"
|
20
|
+
|
21
|
+
# ========================================================================= #
|
22
|
+
# === FILE_ATOMGEWICHTE
|
23
|
+
# ========================================================================= #
|
24
|
+
FILE_ATOMGEWICHTE =
|
25
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/atomgewichte.yml"
|
26
|
+
|
27
|
+
# ========================================================================= #
|
28
|
+
# === ChemistryParadise::Constants::FILE_PERIODIC_TABLE_OF_THE_ELEMENTS
|
29
|
+
# ========================================================================= #
|
30
|
+
FILE_PERIODIC_TABLE_OF_THE_ELEMENTS =
|
31
|
+
"#{PROJECT_BASE_DIRECTORY}yaml/periodic_table_of_the_elements.yml"
|
32
|
+
|
33
|
+
end; end
|
@@ -0,0 +1,157 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# require 'chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb'
|
6
|
+
# =========================================================================== #
|
7
|
+
# This .rb file will translate from the german name of an element towards
|
8
|
+
# the element symbol, if applicable. So, "Quecksilber" will become
|
9
|
+
# "Hg".
|
10
|
+
#
|
11
|
+
# See: https://de.wikipedia.org/wiki/Liste_der_chemischen_Elemente
|
12
|
+
# =========================================================================== #
|
13
|
+
module ChemistryParadise
|
14
|
+
|
15
|
+
# ========================================================================= #
|
16
|
+
# === ChemistryParadise::GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL
|
17
|
+
# ========================================================================= #
|
18
|
+
GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL = {
|
19
|
+
'Actinium' => 'Ac',
|
20
|
+
'Aluminium' => 'Al',
|
21
|
+
'Americium' => 'Am',
|
22
|
+
'Antimon' => 'Sb',
|
23
|
+
'Argon' => 'Ar',
|
24
|
+
'Arsen' => 'As',
|
25
|
+
'Astat' => 'At',
|
26
|
+
'Barium' => 'Ba',
|
27
|
+
'Berkelium' => 'Bk',
|
28
|
+
'Beryllium' => 'Be',
|
29
|
+
'Bismut' => 'Bi',
|
30
|
+
'Blei' => 'Pb',
|
31
|
+
'Bohrium' => 'Bh',
|
32
|
+
'Bor' => 'B',
|
33
|
+
'Brom' => 'Br',
|
34
|
+
'Cadmium' => 'Cd',
|
35
|
+
'Caesium' => 'Cs',
|
36
|
+
'Calcium' => 'Ca',
|
37
|
+
'Californium' => 'Cf',
|
38
|
+
'Cer' => 'Ce',
|
39
|
+
'Chlor' => 'Cl',
|
40
|
+
'Chrom' => 'Cr',
|
41
|
+
'Cobalt' => 'Co',
|
42
|
+
'Copernicium' => 'Cn',
|
43
|
+
'Curium' => 'Cm',
|
44
|
+
'Darmstadtium' => 'Ds',
|
45
|
+
'Dubnium' => 'Db',
|
46
|
+
'Dysprosium' => 'Dy',
|
47
|
+
'Einsteinium' => 'Es',
|
48
|
+
'Eisen' => 'Fe',
|
49
|
+
'Erbium' => 'Er',
|
50
|
+
'Europium' => 'Eu',
|
51
|
+
'Fermium' => 'Fm',
|
52
|
+
'Flerovium' => 'Fl',
|
53
|
+
'Fluor' => 'F',
|
54
|
+
'Francium' => 'Fr',
|
55
|
+
'Gadolinium' => 'Gd',
|
56
|
+
'Gallium' => 'Ga',
|
57
|
+
'Germanium' => 'Ge',
|
58
|
+
'Gold' => 'Au',
|
59
|
+
'Hafnium' => 'Hf',
|
60
|
+
'Hassium' => 'Hs',
|
61
|
+
'Helium' => 'He',
|
62
|
+
'Holmium' => 'Ho',
|
63
|
+
'Indium' => 'In',
|
64
|
+
'Iod' => 'I',
|
65
|
+
'Iridium' => 'Ir ',
|
66
|
+
'Kalium' => 'K',
|
67
|
+
'Kohlenstoff' => 'C',
|
68
|
+
'Krypton' => 'Kr',
|
69
|
+
'Kupfer' => 'Cu',
|
70
|
+
'Lanthan' => 'La',
|
71
|
+
'Lawrencium' => 'Lr',
|
72
|
+
'Lithium' => 'Li',
|
73
|
+
'Livermorium' => 'Lv',
|
74
|
+
'Lutetium' => 'Lu',
|
75
|
+
'Magnesium' => 'Mg',
|
76
|
+
'Mangan' => 'Mn',
|
77
|
+
'Meitnerium' => 'Mt',
|
78
|
+
'Mendelevium' => 'Md',
|
79
|
+
'Molybdän' => 'Mo',
|
80
|
+
'Moscovium' => 'Mc',
|
81
|
+
'Natrium' => 'Na',
|
82
|
+
'Neodym' => 'Nd',
|
83
|
+
'Neon' => 'Ne',
|
84
|
+
'Neptunium' => 'Np',
|
85
|
+
'Nickel' => 'Ni',
|
86
|
+
'Nihonium' => 'Nh',
|
87
|
+
'Niob' => 'Nb',
|
88
|
+
'Nobelium' => 'No',
|
89
|
+
'Oganesson' => 'Og',
|
90
|
+
'Osmium' => 'Os',
|
91
|
+
'Palladium' => 'Pd',
|
92
|
+
'Phosphor' => 'P',
|
93
|
+
'Platin' => 'Pt',
|
94
|
+
'Plutonium' => 'Pu',
|
95
|
+
'Polonium' => 'Po',
|
96
|
+
'Praseodym' => 'Pr',
|
97
|
+
'Promethium' => 'Pm',
|
98
|
+
'Protactinium' => 'Pa',
|
99
|
+
'Quecksilber' => 'Hg',
|
100
|
+
'Radium' => 'Ra',
|
101
|
+
'Radon' => 'Rn',
|
102
|
+
'Rhenium' => 'Re',
|
103
|
+
'Rhodium' => 'Rh',
|
104
|
+
'Roentgenium' => 'Rg',
|
105
|
+
'Rubidium' => 'Rb',
|
106
|
+
'Ruthenium' => 'Ru',
|
107
|
+
'Rutherfordium' => 'Rf',
|
108
|
+
'Samarium' => 'Sm',
|
109
|
+
'Sauerstoff' => 'O',
|
110
|
+
'Scandium' => 'Sc',
|
111
|
+
'Schwefel' => 'S',
|
112
|
+
'Seaborgium' => 'Sg',
|
113
|
+
'Selen' => 'Se',
|
114
|
+
'Silber' => 'Ag',
|
115
|
+
'Silicium' => 'Si',
|
116
|
+
'Stickstoff' => 'N',
|
117
|
+
'Strontium' => 'Sr',
|
118
|
+
'Tantal' => 'Ta',
|
119
|
+
'Technetium' => 'Tc',
|
120
|
+
'Tellur' => 'Te',
|
121
|
+
'Tenness' => 'Ts',
|
122
|
+
'Terbium' => 'Tb',
|
123
|
+
'Thallium' => 'Tl',
|
124
|
+
'Thorium' => 'Th',
|
125
|
+
'Thulium' => 'Tm',
|
126
|
+
'Titan' => 'Ti',
|
127
|
+
'Uran' => 'U',
|
128
|
+
'Vanadium' => 'V',
|
129
|
+
'Wasserstoff' => 'H',
|
130
|
+
'Wolfram' => 'W',
|
131
|
+
'Xenon' => 'Xe',
|
132
|
+
'Ytterbium' => 'Yb',
|
133
|
+
'Yttrium' => 'Y',
|
134
|
+
'Zink' => 'Zn',
|
135
|
+
'Zinn' => 'Sn',
|
136
|
+
'Zirconium' => 'Zr'
|
137
|
+
}
|
138
|
+
|
139
|
+
# ========================================================================= #
|
140
|
+
# === ChemistryParadise.return_element_symbol_from_this_german_name
|
141
|
+
# ========================================================================= #
|
142
|
+
def self.return_element_symbol_from_this_german_name(i)
|
143
|
+
i = i.dup if i.frozen?
|
144
|
+
i.capitalize!
|
145
|
+
if GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL.has_key? i
|
146
|
+
GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL[i]
|
147
|
+
else
|
148
|
+
nil
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
if __FILE__ == $PROGRAM_NAME
|
155
|
+
puts ChemistryParadise::GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL['Quecksilber']
|
156
|
+
puts ChemistryParadise.return_element_symbol_from_this_german_name('quecksilber')
|
157
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === CelsiusToFahrenheit
|
6
|
+
#
|
7
|
+
# Celsius was defined by the freezing point of water (and later the melting
|
8
|
+
# point of ice). Nowadays, the Celsius scale is a derived scale, defined in
|
9
|
+
# relation to the Kelvin temperature scale.
|
10
|
+
#
|
11
|
+
# Zero on the Celsius scale (0°C) is defined as the equivalent to 273.15 K.
|
12
|
+
#
|
13
|
+
# The Celsius scale is an interval system but not a ratio system, meaning
|
14
|
+
# it follows a relative scale but not an absolute scale.
|
15
|
+
#
|
16
|
+
# A temperature difference of 1 deg C is the equivalent of a temperature
|
17
|
+
# difference 1.8°F (which is 9/5).
|
18
|
+
#
|
19
|
+
# Usage example:
|
20
|
+
#
|
21
|
+
# ChemistryParadise::CelsiusToFahrenheit.new(ARGV)
|
22
|
+
#
|
23
|
+
# =========================================================================== #
|
24
|
+
# require 'chemistry_paradise/converters/celsius_to_fahrenheit.rb'
|
25
|
+
# =========================================================================== #
|
26
|
+
module ChemistryParadise
|
27
|
+
|
28
|
+
class CelsiusToFahrenheit # === ChemistryPAradise::CelsiusToFahrenheit
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'colours'
|
32
|
+
include Colours
|
33
|
+
rescue LoadError; end
|
34
|
+
|
35
|
+
begin
|
36
|
+
require 'opn'
|
37
|
+
rescue LoadError; end
|
38
|
+
|
39
|
+
require 'chemistry_paradise/converters/shared.rb'
|
40
|
+
include ChemistryParadise::Converters
|
41
|
+
|
42
|
+
# ========================================================================= #
|
43
|
+
# === NAMESPACE
|
44
|
+
# ========================================================================= #
|
45
|
+
NAMESPACE = 'ChemistryParadise::CelsiusToFahrenheit'
|
46
|
+
|
47
|
+
# ========================================================================= #
|
48
|
+
# === initialize
|
49
|
+
# ========================================================================= #
|
50
|
+
def initialize(
|
51
|
+
celsius = 0,
|
52
|
+
run_already = true
|
53
|
+
)
|
54
|
+
reset
|
55
|
+
set_celsius(celsius)
|
56
|
+
run if run_already
|
57
|
+
end
|
58
|
+
|
59
|
+
# ========================================================================= #
|
60
|
+
# === reset (reset tag)
|
61
|
+
# ========================================================================= #
|
62
|
+
def reset
|
63
|
+
set_celsius
|
64
|
+
end
|
65
|
+
|
66
|
+
# ========================================================================= #
|
67
|
+
# === set_celsius
|
68
|
+
# ========================================================================= #
|
69
|
+
def set_celsius(i = 0)
|
70
|
+
i = i.first if i.is_a? Array
|
71
|
+
i = i.to_s.dup
|
72
|
+
i = i.to_f
|
73
|
+
@celsius = i
|
74
|
+
end
|
75
|
+
|
76
|
+
# ========================================================================= #
|
77
|
+
# === do_the_calculation
|
78
|
+
#
|
79
|
+
# We determine how many Fahrenheit we have here, by using the
|
80
|
+
# specific formula.
|
81
|
+
# ========================================================================= #
|
82
|
+
def do_the_calculation
|
83
|
+
@fahrenheit = (@celsius * CELSIUS_TO_FAHRENHEIT_CONVERSION_FACTOR)+32.00
|
84
|
+
end
|
85
|
+
|
86
|
+
# ========================================================================= #
|
87
|
+
# === input?
|
88
|
+
# ========================================================================= #
|
89
|
+
def celsius?
|
90
|
+
@celsius
|
91
|
+
end; alias n_celsius celsius? # === n_celsius
|
92
|
+
|
93
|
+
# ========================================================================= #
|
94
|
+
# === fahrenheit?
|
95
|
+
# ========================================================================= #
|
96
|
+
def fahrenheit?
|
97
|
+
@fahrenheit
|
98
|
+
end; alias n_fahrenheit fahrenheit? # === fahrenheit?
|
99
|
+
|
100
|
+
# ========================================================================= #
|
101
|
+
# === report_result
|
102
|
+
# ========================================================================= #
|
103
|
+
def report_result
|
104
|
+
opnn if use_opn?
|
105
|
+
e n_celsius.to_s+'° '+simp('Celsius')+' are '+n_fahrenheit.to_s+
|
106
|
+
'° '+simp('Fahrenheit')+'.'
|
107
|
+
end; alias report report_result # === report
|
108
|
+
|
109
|
+
# ========================================================================= #
|
110
|
+
# === use_opn?
|
111
|
+
# ========================================================================= #
|
112
|
+
def use_opn?
|
113
|
+
false
|
114
|
+
end
|
115
|
+
|
116
|
+
# ========================================================================= #
|
117
|
+
# === opnn
|
118
|
+
# ========================================================================= #
|
119
|
+
def opnn
|
120
|
+
Opn.opn(use_this_as_namespace: NAMESPACE)
|
121
|
+
end
|
122
|
+
|
123
|
+
# ========================================================================= #
|
124
|
+
# === run (run tag)
|
125
|
+
# ========================================================================= #
|
126
|
+
def run
|
127
|
+
do_the_calculation
|
128
|
+
end
|
129
|
+
|
130
|
+
# ========================================================================= #
|
131
|
+
# === CelsiusToFahrenheit[]
|
132
|
+
# ========================================================================= #
|
133
|
+
def self.[](i)
|
134
|
+
_ = CelsiusToFahrenheit.new(i)
|
135
|
+
_.report
|
136
|
+
end
|
137
|
+
|
138
|
+
end; end
|
139
|
+
|
140
|
+
if __FILE__ == $PROGRAM_NAME
|
141
|
+
_ = ChemistryParadise::CelsiusToFahrenheit.new(ARGV)
|
142
|
+
_.report_result
|
143
|
+
end # celsiustofahrenheit2 50
|