chemistry_paradise 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +657 -0
  3. data/bin/chemistry_paradise +7 -0
  4. data/bin/wetter +7 -0
  5. data/chemistry_paradise.gemspec +46 -0
  6. data/doc/README.gen +595 -0
  7. data/doc/bugs/BUGS.md +16 -0
  8. data/doc/formulas/biochemical_calculations.md +5 -0
  9. data/doc/todo/todo_for_the_chemistry_paradise_project.md +33 -0
  10. data/doc/todo/todo_for_the_wetter_project.md +7 -0
  11. data/lib/chemistry_paradise/base/base.rb +215 -0
  12. data/lib/chemistry_paradise/base/colours.rb +93 -0
  13. data/lib/chemistry_paradise/commandline/help.rb +40 -0
  14. data/lib/chemistry_paradise/commandline/menu.rb +88 -0
  15. data/lib/chemistry_paradise/commandline/parse_commandline.rb +94 -0
  16. data/lib/chemistry_paradise/constants/constants.rb +77 -0
  17. data/lib/chemistry_paradise/constants/constants_for_chemical_formulas.rb +16 -0
  18. data/lib/chemistry_paradise/constants/file_constants.rb +33 -0
  19. data/lib/chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb +157 -0
  20. data/lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb +143 -0
  21. data/lib/chemistry_paradise/converters/celsius_to_kelvin.rb +125 -0
  22. data/lib/chemistry_paradise/converters/fahrenheit_to_celsius.rb +132 -0
  23. data/lib/chemistry_paradise/converters/shared.rb +21 -0
  24. data/lib/chemistry_paradise/gui/gtk3/calculate_molecular_weight/calculate_molecular_weight.rb +34 -0
  25. data/lib/chemistry_paradise/gui/gtk3/show_periodic_table/show_periodic_table.rb +34 -0
  26. data/lib/chemistry_paradise/gui/gtk3/temperature_converter/temperature_converter.rb +112 -0
  27. data/lib/chemistry_paradise/gui/gtk3/wetter/wetter.rb +119 -0
  28. data/lib/chemistry_paradise/gui/libui/temperature_converter/temperature_converter.rb +100 -0
  29. data/lib/chemistry_paradise/gui/libui/wetter/wetter.rb +47 -0
  30. data/lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb +171 -0
  31. data/lib/chemistry_paradise/gui/shared_code/show_periodic_table/show_periodic_table_module.rb +318 -0
  32. data/lib/chemistry_paradise/gui/shared_code/temperature_converter/temperature_converter_module.rb +192 -0
  33. data/lib/chemistry_paradise/gui/shared_code/wetter/wetter_module.rb +349 -0
  34. data/lib/chemistry_paradise/gui/swing/TemperatureConverter$1.class +0 -0
  35. data/lib/chemistry_paradise/gui/swing/TemperatureConverter.class +0 -0
  36. data/lib/chemistry_paradise/gui/swing/TemperatureConverter.java +133 -0
  37. data/lib/chemistry_paradise/gui/unified_widgets/wetter/wetter.rb +62 -0
  38. data/lib/chemistry_paradise/images/show_periodic_table.png +0 -0
  39. data/lib/chemistry_paradise/images/vienna_map.png +0 -0
  40. data/lib/chemistry_paradise/interactive_chemistry_shell.rb +246 -0
  41. data/lib/chemistry_paradise/project/project.rb +24 -0
  42. data/lib/chemistry_paradise/requires/common_external_requires.rb +17 -0
  43. data/lib/chemistry_paradise/requires/require_the_project.rb +21 -0
  44. data/lib/chemistry_paradise/requires/require_the_project_including_the_graphical_user_interface.rb +7 -0
  45. data/lib/chemistry_paradise/requires/require_the_project_including_the_web_interface.rb +4 -0
  46. data/lib/chemistry_paradise/shared.rb +130 -0
  47. data/lib/chemistry_paradise/show_electron_configuration.rb +250 -0
  48. data/lib/chemistry_paradise/show_element.rb +145 -0
  49. data/lib/chemistry_paradise/sinatra/sinatra.rb +131 -0
  50. data/lib/chemistry_paradise/sinatra/wetter/app.rb +68 -0
  51. data/lib/chemistry_paradise/sinatra/wetter/start_sinatra_interface.rb +31 -0
  52. data/lib/chemistry_paradise/split_molecule_names.rb +228 -0
  53. data/lib/chemistry_paradise/toplevel_methods/atomgewichte.rb +31 -0
  54. data/lib/chemistry_paradise/toplevel_methods/convert_parens.rb +64 -0
  55. data/lib/chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb +24 -0
  56. data/lib/chemistry_paradise/toplevel_methods/e.rb +16 -0
  57. data/lib/chemistry_paradise/toplevel_methods/kelvin.rb +34 -0
  58. data/lib/chemistry_paradise/toplevel_methods/language.rb +50 -0
  59. data/lib/chemistry_paradise/toplevel_methods/misc.rb +228 -0
  60. data/lib/chemistry_paradise/toplevel_methods/periodic_table.rb +16 -0
  61. data/lib/chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb +63 -0
  62. data/lib/chemistry_paradise/toplevel_methods/roebe.rb +16 -0
  63. data/lib/chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb +26 -0
  64. data/lib/chemistry_paradise/utility_scripts/calculate_atomic_mass.rb +559 -0
  65. data/lib/chemistry_paradise/utility_scripts/combustion_analysis.rb +207 -0
  66. data/lib/chemistry_paradise/utility_scripts/electron_negativity_chart.rb +78 -0
  67. data/lib/chemistry_paradise/utility_scripts/equalize_chemical_formula.rb +84 -0
  68. data/lib/chemistry_paradise/utility_scripts/equation_solver.rb +130 -0
  69. data/lib/chemistry_paradise/utility_scripts/orbitals.rb +70 -0
  70. data/lib/chemistry_paradise/utility_scripts/show_electron_negativity_of_this_element.rb +103 -0
  71. data/lib/chemistry_paradise/utility_scripts/show_periodic_table.rb +996 -0
  72. data/lib/chemistry_paradise/verbose_chemical_calculation.rb +21 -0
  73. data/lib/chemistry_paradise/version/version.rb +19 -0
  74. data/lib/chemistry_paradise/wetter/wetter.rb +539 -0
  75. data/lib/chemistry_paradise/www/wetter/embeddable_interface.rb +78 -0
  76. data/lib/chemistry_paradise/www/wetter/wetter.cgi +28 -0
  77. data/lib/chemistry_paradise/yaml/atomgewichte.yml +139 -0
  78. data/lib/chemistry_paradise/yaml/colours_for_the_elements.yml +13 -0
  79. data/lib/chemistry_paradise/yaml/dichte.yml +21 -0
  80. data/lib/chemistry_paradise/yaml/electron_negativity_chart.yml +111 -0
  81. data/lib/chemistry_paradise/yaml/molecular_formula_of_different_molecules.yml +13 -0
  82. data/lib/chemistry_paradise/yaml/periodic_table_of_the_elements.yml +125 -0
  83. data/lib/chemistry_paradise.rb +1 -0
  84. data/test/testing_chemistry_paradise.rb +49 -0
  85. metadata +175 -0
@@ -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
8
+ # melting point of ice). Nowadays, the Celsius scale is a derived
9
+ # scale, defined in 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 = inspect
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 = ARGV)
134
+ _ = 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
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === CelsiusToKelvin
6
+ #
7
+ # Usage example:
8
+ #
9
+ # ChemistryParadise::CelsiusToKelvin.new(ARGV)
10
+ #
11
+ # =========================================================================== #
12
+ # require 'chemistry_paradise/converters/celsius_to_kelvin.rb'
13
+ # =========================================================================== #
14
+ module ChemistryParadise
15
+
16
+ class CelsiusToKelvin # === ChemistryParadise::CelsiusToKelvin
17
+
18
+ begin
19
+ require 'colours'
20
+ include Colours
21
+ rescue LoadError; end
22
+
23
+ begin
24
+ require 'opn'
25
+ rescue LoadError; end
26
+
27
+ require 'chemistry_paradise/converters/shared.rb'
28
+ include ChemistryParadise::Converters
29
+
30
+ # ========================================================================= #
31
+ # === NAMESPACE
32
+ # ========================================================================= #
33
+ NAMESPACE = inspect
34
+
35
+ # ========================================================================= #
36
+ # === initialize
37
+ # ========================================================================= #
38
+ def initialize(
39
+ celsius = 0,
40
+ run_already = true
41
+ )
42
+ reset
43
+ set_celsius(celsius)
44
+ run if run_already
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === reset (reset tag)
49
+ # ========================================================================= #
50
+ def reset
51
+ set_celsius
52
+ end
53
+
54
+ # ========================================================================= #
55
+ # === set_celsius
56
+ # ========================================================================= #
57
+ def set_celsius(i = 0)
58
+ i = i.first if i.is_a? Array
59
+ i = i.to_s.dup
60
+ i = i.to_f # Store as a Float.
61
+ @celsius = i
62
+ end
63
+
64
+ # ========================================================================= #
65
+ # === do_the_calculation
66
+ #
67
+ # We determine how many Fahrenheit we have here, by using the
68
+ # specific formula.
69
+ # ========================================================================= #
70
+ def do_the_calculation
71
+ @kelvin = @celsius + 273.15
72
+ end
73
+
74
+ # ========================================================================= #
75
+ # === input?
76
+ # ========================================================================= #
77
+ def celsius?
78
+ @celsius
79
+ end; alias n_celsius celsius? # === n_celsius
80
+
81
+ # ========================================================================= #
82
+ # === report_result
83
+ # ========================================================================= #
84
+ def report_result
85
+ opnn if use_opn?
86
+ e rev+
87
+ n_celsius.to_s+'° '+simp('Celsius')+' are '+@kelvin.to_s+
88
+ ' '+simp('Kelvin')+'.'
89
+ end; alias report report_result # === report
90
+
91
+ # ========================================================================= #
92
+ # === use_opn?
93
+ # ========================================================================= #
94
+ def use_opn?
95
+ false
96
+ end
97
+
98
+ # ========================================================================= #
99
+ # === opnn
100
+ # ========================================================================= #
101
+ def opnn
102
+ Opn.opn(use_this_as_namespace: NAMESPACE)
103
+ end
104
+
105
+ # ========================================================================= #
106
+ # === run (run tag)
107
+ # ========================================================================= #
108
+ def run
109
+ do_the_calculation
110
+ end
111
+
112
+ # ========================================================================= #
113
+ # === CelsiusToKelvin[]
114
+ # ========================================================================= #
115
+ def self.[](i = ARGV)
116
+ _ = new(i)
117
+ _.report
118
+ end
119
+
120
+ end; end
121
+
122
+ if __FILE__ == $PROGRAM_NAME
123
+ _ = ChemistryParadise::CelsiusToKelvin.new(ARGV)
124
+ _.report_result
125
+ end # CelsiusToKelvin2 50
@@ -0,0 +1,132 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ChemistryParadise::FahrenheitToCelsius
6
+ #
7
+ # Usage example:
8
+ #
9
+ # ChemistryParadise::FahrenheitToCelsius.new
10
+ #
11
+ # =========================================================================== #
12
+ # require 'chemistry_paradise/converters/fahrenheit_to_celsius.rb'
13
+ # =========================================================================== #
14
+ module ChemistryParadise
15
+
16
+ class FahrenheitToCelsius # === ChemistryParadise::FahrenheitToCelsius
17
+
18
+ require 'chemistry_paradise/converters/shared.rb'
19
+
20
+ begin
21
+ require 'opn'
22
+ rescue LoadError; end
23
+
24
+ begin
25
+ require 'colours'
26
+ include Colours
27
+ rescue LoadError; end
28
+
29
+ include ChemistryParadise::Converters
30
+
31
+ # ========================================================================= #
32
+ # === NAMESPACE
33
+ # ========================================================================= #
34
+ NAMESPACE = inspect
35
+
36
+ # ========================================================================= #
37
+ # === initialize
38
+ # ========================================================================= #
39
+ def initialize(
40
+ fahrenheit = 0,
41
+ run_already = true
42
+ )
43
+ reset
44
+ set_fahrenheit(fahrenheit)
45
+ run if run_already
46
+ end
47
+
48
+ # ========================================================================= #
49
+ # === reset (reset tag)
50
+ # ========================================================================= #
51
+ def reset
52
+ set_fahrenheit
53
+ end
54
+
55
+ # ========================================================================= #
56
+ # === set_fahrenheit
57
+ # ========================================================================= #
58
+ def set_fahrenheit(i = 0)
59
+ i = i.first if i.is_a? Array
60
+ i = i.to_s.dup
61
+ i = i.to_f
62
+ @fahrenheit = i
63
+ end
64
+
65
+ # ========================================================================= #
66
+ # === do_the_calculation
67
+ #
68
+ # We determine how many Fahrenheit we have here, by using the
69
+ # specific formula.
70
+ # ========================================================================= #
71
+ def do_the_calculation
72
+ @celsius = (@fahrenheit - 32) / FAHRENHEIT_TO_CELSIUS_CONVERSION_FACTOR
73
+ end
74
+
75
+ # ========================================================================= #
76
+ # === fahrenheit?
77
+ # ========================================================================= #
78
+ def fahrenheit?
79
+ @fahrenheit
80
+ end; alias n_fahrenheit fahrenheit? # === fahrenheit?
81
+
82
+ # ========================================================================= #
83
+ # === input?
84
+ # ========================================================================= #
85
+ def celsius?
86
+ @celsius
87
+ end; alias n_celsius celsius? # === n_celsius
88
+
89
+ # ========================================================================= #
90
+ # === run (run tag)
91
+ # ========================================================================= #
92
+ def run
93
+ do_the_calculation
94
+ end
95
+
96
+ # ========================================================================= #
97
+ # === report_result
98
+ # ========================================================================= #
99
+ def report_result
100
+ opnn if use_opn?
101
+ e n_fahrenheit.to_s+'° '+simp('Fahrenheit')+' are '+n_celsius.round(2).to_s+
102
+ '° '+simp('Celsius')+'.'
103
+ end; alias report report_result # === report
104
+
105
+ # ========================================================================= #
106
+ # === use_opn?
107
+ # ========================================================================= #
108
+ def use_opn?
109
+ false
110
+ end
111
+
112
+ # ========================================================================= #
113
+ # === opnn
114
+ # ========================================================================= #
115
+ def opnn
116
+ Opn.opn(use_this_as_namespace: NAMESPACE)
117
+ end
118
+
119
+ # ========================================================================= #
120
+ # === ChemistryParadise::FahrenheitToCelsius[]
121
+ # ========================================================================= #
122
+ def self.[](i)
123
+ _ = FahrenheitToCelsius.new(i)
124
+ _.report
125
+ end
126
+
127
+ end; end
128
+
129
+ if __FILE__ == $PROGRAM_NAME
130
+ _ = ChemistryParadise::FahrenheitToCelsius.new(ARGV)
131
+ _.report_result
132
+ end # fahrenheittocelsius2 50
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'chemistry_paradise/converters/shared.rb'
6
+ # =========================================================================== #
7
+ module ChemistryParadise
8
+
9
+ module Converters # === include ChemistryParadise::Converters
10
+
11
+ # ========================================================================= #
12
+ # === CELSIUS_TO_FAHRENHEIT_CONVERSION_FACTOR
13
+ # ========================================================================= #
14
+ CELSIUS_TO_FAHRENHEIT_CONVERSION_FACTOR = 1.8000
15
+
16
+ # ========================================================================= #
17
+ # === FAHRENHEIT_TO_CELSIUS_CONVERSION_FACTOR
18
+ # ========================================================================= #
19
+ FAHRENHEIT_TO_CELSIUS_CONVERSION_FACTOR = 1 / ( 5.0 / 9)
20
+
21
+ end; end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ChemistryParadise::GUI::Gtk::CalculateMolecularWeight
6
+ # =========================================================================== #
7
+ # require 'chemistry_paradise/gui/gtk3/chemistry_paradise/chemistry_paradise.rb'
8
+ # ChemistryParadise::GUI::Gtk::CalculateMolecularWeight.run
9
+ # =========================================================================== #
10
+ require 'gtk_paradise/require_gtk3'
11
+
12
+ module ChemistryParadise
13
+
14
+ module GUI
15
+
16
+ module Gtk
17
+
18
+ class CalculateMolecularWeight < ::Gtk::Box
19
+
20
+ require 'chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb'
21
+ include ::ChemistryParadise::GUI::Gtk::CalculateMolecularWeightModule
22
+
23
+ # ========================================================================= #
24
+ # === ChemistryParadise::GUI::Gtk::CalculateMolecularWeight.run
25
+ # ========================================================================= #
26
+ def self.run
27
+ ::ChemistryParadise::GUI::Gtk::CalculateMolecularWeightModule.run
28
+ end
29
+
30
+ end; end; end; end
31
+
32
+ if __FILE__ == $PROGRAM_NAME
33
+ ChemistryParadise::GUI::Gtk::CalculateMolecularWeight.run
34
+ end
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === ChemistryParadise::GUI::Gtk::ShowPeriodicTable
6
+ # =========================================================================== #
7
+ # require 'chemistry_paradise/gui/gtk3/show_periodic_table/show_periodic_table.rb'
8
+ # ChemistryParadise::GUI::Gtk::ShowPeriodicTable.run
9
+ # =========================================================================== #
10
+ require 'gtk_paradise/require_gtk3'
11
+
12
+ module ChemistryParadise
13
+
14
+ module GUI
15
+
16
+ module Gtk
17
+
18
+ class ShowPeriodicTable < ::Gtk::Box
19
+
20
+ require 'chemistry_paradise/gui/shared_code/show_periodic_table/show_periodic_table_module.rb'
21
+ include ::ChemistryParadise::GUI::Gtk::ShowPeriodicTableModule
22
+
23
+ # ========================================================================= #
24
+ # === ChemistryParadise::GUI::Gtk::ShowPeriodicTable.run
25
+ # ========================================================================= #
26
+ def self.run
27
+ ::ChemistryParadise::GUI::Gtk::ShowPeriodicTableModule.run
28
+ end
29
+
30
+ end; end; end; end
31
+
32
+ if __FILE__ == $PROGRAM_NAME
33
+ ChemistryParadise::GUI::Gtk::ShowPeriodicTable.run
34
+ end