Class: ChemistryParadise::CombustionAnalysis
- Inherits:
-
Base
- Object
- Base
- ChemistryParadise::CombustionAnalysis
show all
- Defined in:
- lib/chemistry_paradise/utility_scripts/combustion_analysis.rb
Overview
ChemistryParadise::CombustionAnalysis
Constant Summary
Constants inherited
from Base
Base::FILE_MOLECULAR_FORMULA_OF_DIFFERENT_MOLECULES, Base::NAMESPACE
Constants included
from Shared
Shared::ARRAY_TEST_THESE_MOLECULES
Constants included
from Constants
ChemistryParadise::Constants::ELECTRON_NEGATIVITY_CHART, ChemistryParadise::Constants::FILE_ATOMGEWICHTE, ChemistryParadise::Constants::FILE_ELECTRON_NEGATIVITY_CHART, ChemistryParadise::Constants::FILE_PERIODIC_TABLE_OF_THE_ELEMENTS, ChemistryParadise::Constants::N, ChemistryParadise::Constants::PLANK_CONSTANT, ChemistryParadise::Constants::PROPER_FILLORDER, ChemistryParadise::Constants::SPEED_OF_LIGHT
Class Method Summary
collapse
-
.[](i = '') ⇒ Object
# === CombustionAnalysis[] ========================================================================= #.
Instance Method Summary
collapse
Methods inherited from Base
#be_quiet, #be_verbose?, #cd, #cliner, #commandline_arguments?, #do_use_the_english_language, #do_use_the_german_language, #do_we_use_english?, #esystem, #first_argument?, #gold, #grey, #initialize_the_internal_hash, #internal_hash?, #is_on_roebe?, #mediumpurple, #namespace?, #olivedrab, #opnn, #rev, #royalblue, #set_be_verbose, #set_commandline_arguments, #sfancy, #steelblue, #teal, #tomato, #use_which_language?, #yellow
Methods included from Shared
#convert_parens, #is_number?, #periodic_table?, periodic_table?, #return_range_for_this_period, #square
Methods included from Constants
#electron_negativity_chart?
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ CombustionAnalysis
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 27
def initialize(
commandline_arguments = nil,
run_already = true
)
reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
198
199
200
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 198
def self.[](i = '')
new(i)
end
|
Instance Method Details
#determine_the_result ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 148
def determine_the_result
@result = @hash_ratio.map {|k, v|
v = v.to_i
case v
when 1
v = '₁'
when 2
v = '₂'
when 3
v = '₃'
when 4
v = '₄'
when 5
v = '₅'
when 6
v = '₆'
when 7
v = '₇'
when 8
v = '₈'
when 9
v = '₉'
when 12
v = '₁₂'
end
"#{k}#{v}"
}.join
end
|
#does_the_main_hash_have_an_uneven_value? ⇒ Boolean
#
does_the_main_hash_have_an_uneven_value?
This method will return true if we have an uneven value in the main Hash, such as 1.5.
#
125
126
127
128
129
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 125
def does_the_main_hash_have_an_uneven_value?
@hash_ratio.values.any? {|entry|
(entry - entry.floor) > 0
}
end
|
#further_process_the_main_hash ⇒ Object
#
further_process_the_main_hash
This method is specifically to turn e. g. a 1.5 into a 3.0.
#
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 102
def further_process_the_main_hash
first_zero_point_result = @hash_ratio.select {|key, value|
value - value.floor == 0.5
}
if first_zero_point_result
@hash_ratio.transform_values! {|value|
value * 2.0
}
end
end
|
#hash_ratio? ⇒ Boolean
Also known as:
hash?
134
135
136
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 134
def hash_ratio?
@hash_ratio
end
|
#parse_the_main_input(i) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 52
def parse_the_main_input(i)
dataset = YAML.load_file(FILE_ATOMGEWICHTE)
if i.is_a?(String) and i.include?('%')
splitted = i.split('%').map(&:strip)
splitted.each {|entry|
entry.tr!(',','.')
inner_splitted = entry.split(' ')
first = inner_splitted.first
last = inner_splitted.last.to_f
@hash_ratio[first] = last / dataset[first]
}
end
end
|
#report ⇒ Object
141
142
143
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 141
def report
e @result
end
|
#reset ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 41
def reset
super()
@hash_ratio = {}
end
|
#result? ⇒ Boolean
180
181
182
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 180
def result?
@result
end
|
#run ⇒ Object
187
188
189
190
191
192
193
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 187
def run
_ = first?
parse_the_main_input(_)
work_on_the_hash_ratio
determine_the_result
report
end
|
#work_on_the_hash_ratio ⇒ Object
#
work_on_the_hash_ratio
#
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/chemistry_paradise/utility_scripts/combustion_analysis.rb', line 78
def work_on_the_hash_ratio
min_element = @hash_ratio.min
ratio = 1.0 / min_element.last
@hash_ratio.transform_values! {|values|
(values * ratio).round(1)
}
if does_the_main_hash_have_an_uneven_value?
further_process_the_main_hash
end
end
|