Module: ChemistryParadise

Defined in:
lib/chemistry_paradise/shared.rb,
lib/chemistry_paradise/base/base.rb,
lib/chemistry_paradise/base/colours.rb,
lib/chemistry_paradise/show_element.rb,
lib/chemistry_paradise/wetter/wetter.rb,
lib/chemistry_paradise/project/project.rb,
lib/chemistry_paradise/sinatra/sinatra.rb,
lib/chemistry_paradise/version/version.rb,
lib/chemistry_paradise/commandline/help.rb,
lib/chemistry_paradise/commandline/menu.rb,
lib/chemistry_paradise/converters/shared.rb,
lib/chemistry_paradise/sinatra/wetter/app.rb,
lib/chemistry_paradise/toplevel_methods/e.rb,
lib/chemistry_paradise/constants/constants.rb,
lib/chemistry_paradise/split_molecule_names.rb,
lib/chemistry_paradise/toplevel_methods/misc.rb,
lib/chemistry_paradise/gui/gtk3/wetter/wetter.rb,
lib/chemistry_paradise/toplevel_methods/roebe.rb,
lib/chemistry_paradise/gui/libui/wetter/wetter.rb,
lib/chemistry_paradise/toplevel_methods/kelvin.rb,
lib/chemistry_paradise/constants/file_constants.rb,
lib/chemistry_paradise/utility_scripts/orbitals.rb,
lib/chemistry_paradise/toplevel_methods/language.rb,
lib/chemistry_paradise/interactive_chemistry_shell.rb,
lib/chemistry_paradise/show_electron_configuration.rb,
lib/chemistry_paradise/converters/celsius_to_kelvin.rb,
lib/chemistry_paradise/verbose_chemical_calculation.rb,
lib/chemistry_paradise/commandline/parse_commandline.rb,
lib/chemistry_paradise/toplevel_methods/atomgewichte.rb,
lib/chemistry_paradise/toplevel_methods/convert_parens.rb,
lib/chemistry_paradise/toplevel_methods/periodic_table.rb,
lib/chemistry_paradise/utility_scripts/equation_solver.rb,
lib/chemistry_paradise/www/wetter/embeddable_interface.rb,
lib/chemistry_paradise/converters/celsius_to_fahrenheit.rb,
lib/chemistry_paradise/converters/fahrenheit_to_celsius.rb,
lib/chemistry_paradise/gui/unified_widgets/wetter/wetter.rb,
lib/chemistry_paradise/utility_scripts/combustion_analysis.rb,
lib/chemistry_paradise/utility_scripts/show_periodic_table.rb,
lib/chemistry_paradise/gui/shared_code/wetter/wetter_module.rb,
lib/chemistry_paradise/utility_scripts/calculate_atomic_mass.rb,
lib/chemistry_paradise/sinatra/wetter/start_sinatra_interface.rb,
lib/chemistry_paradise/constants/constants_for_chemical_formulas.rb,
lib/chemistry_paradise/utility_scripts/electron_negativity_chart.rb,
lib/chemistry_paradise/utility_scripts/equalize_chemical_formula.rb,
lib/chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb,
lib/chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb,
lib/chemistry_paradise/gui/gtk3/show_periodic_table/show_periodic_table.rb,
lib/chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb,
lib/chemistry_paradise/gui/gtk3/temperature_converter/temperature_converter.rb,
lib/chemistry_paradise/gui/libui/temperature_converter/temperature_converter.rb,
lib/chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb,
lib/chemistry_paradise/utility_scripts/show_electron_negativity_of_this_element.rb,
lib/chemistry_paradise/gui/gtk3/calculate_molecular_weight/calculate_molecular_weight.rb,
lib/chemistry_paradise/gui/shared_code/show_periodic_table/show_periodic_table_module.rb,
lib/chemistry_paradise/gui/shared_code/temperature_converter/temperature_converter_module.rb,
lib/chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb

Overview

#

ChemistryParadise::GUI::Gtk::CalculateMolecularWeightModule

#

require ‘chemistry_paradise/gui/shared_code/calculate_molecular_weight/calculate_molecular_weight_module.rb’ include ::ChemistryParadise::GUI::Gtk::CalculateMolecularWeightModule

#

Defined Under Namespace

Modules: Constants, ConstantsForChemicalFormulas, Converters, GUI, Shared Classes: Base, CalculateAtomicMass, CelsiusToFahrenheit, CelsiusToKelvin, CombustionAnalysis, ElectronNegativityChart, EqualizeChemicalFormula, EquationSolver, FahrenheitToCelsius, InteractiveChemistryShell, Orbitals, ParseCommandline, ShowElectronConfiguration, ShowElectronNegativityOfThisElement, ShowElement, ShowPeriodicTable, Sinatra, SplitMoleculeNames, VerboseChemicalCalculation, Wetter

Constant Summary collapse

PROJECT_BASE_DIRECTORY =
#

PROJECT_BASE_DIRECTORY

The constant must have a trailing ‘/’ character.

#
File.absolute_path("#{__dir__}/..")+'/'
VERSION =
#

VERSION

#
'1.4.2'
LAST_UPDATE =
#

LAST_UPDATE

#
'10.11.2023'
GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL =
#

ChemistryParadise::GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL

#
{
  'Actinium'      => 'Ac',
  'Aluminium'     => 'Al',
  'Americium'     => 'Am',
  'Antimon'       => 'Sb',
  'Argon'         => 'Ar',
  'Arsen'         => 'As',
  'Astat'         => 'At',
  'Barium'        => 'Ba',
  'Berkelium'     => 'Bk',
  'Beryllium'     => 'Be',
  'Bismut'        => 'Bi',
  'Blei'          => 'Pb',
  'Bohrium'       => 'Bh',
  'Bor'           => 'B',
  'Brom'          => 'Br',
  'Cadmium'       => 'Cd',
  'Caesium'       => 'Cs',
  'Calcium'       => 'Ca',
  'Californium'   => 'Cf',
  'Cer'           => 'Ce',
  'Chlor'         => 'Cl',
  'Chrom'         => 'Cr',
  'Cobalt'        => 'Co',
  'Copernicium'   => 'Cn',
  'Curium'        => 'Cm',
  'Darmstadtium'  => 'Ds',
  'Dubnium'       => 'Db',
  'Dysprosium'    => 'Dy',
  'Einsteinium'   => 'Es',
  'Eisen'         => 'Fe',
  'Erbium'        => 'Er',
  'Europium'      => 'Eu',
  'Fermium'       => 'Fm',
  'Flerovium'     => 'Fl',
  'Fluor'         => 'F',
  'Francium'      => 'Fr',
  'Gadolinium'    => 'Gd',
  'Gallium'       => 'Ga',
  'Germanium'     => 'Ge',
  'Gold'          => 'Au',
  'Hafnium'       => 'Hf',
  'Hassium'       => 'Hs',
  'Helium'        => 'He',
  'Holmium'       => 'Ho',
  'Indium'        => 'In',
  'Iod'           => 'I',
  'Iridium'       => 'Ir ',
  'Kalium'        => 'K',
  'Kohlenstoff'   => 'C',
  'Krypton'       => 'Kr',
  'Kupfer'        => 'Cu',
  'Lanthan'       => 'La',
  'Lawrencium'    => 'Lr',
  'Lithium'       => 'Li',
  'Livermorium'   => 'Lv',
  'Lutetium'      => 'Lu',
  'Magnesium'     => 'Mg',
  'Mangan'        => 'Mn',
  'Meitnerium'    => 'Mt',
  'Mendelevium'   => 'Md',
  'Molybdän'      => 'Mo',
  'Moscovium'     => 'Mc',
  'Natrium'       => 'Na',
  'Neodym'        => 'Nd',
  'Neon'          => 'Ne',
  'Neptunium'     => 'Np',
  'Nickel'        => 'Ni',
  'Nihonium'      => 'Nh',
  'Niob'          => 'Nb',
  'Nobelium'      => 'No',
  'Oganesson'     => 'Og',
  'Osmium'        => 'Os',
  'Palladium'     => 'Pd',
  'Phosphor'      => 'P',
  'Platin'        => 'Pt',
  'Plutonium'     => 'Pu',
  'Polonium'      => 'Po',
  'Praseodym'     => 'Pr',
  'Promethium'    => 'Pm',
  'Protactinium'  => 'Pa',
  'Quecksilber'   => 'Hg',
  'Radium'        => 'Ra',
  'Radon'         => 'Rn',
  'Rhenium'       => 'Re',
  'Rhodium'       => 'Rh',
  'Roentgenium'   => 'Rg',
  'Rubidium'      => 'Rb',
  'Ruthenium'     => 'Ru',
  'Rutherfordium' => 'Rf',
  'Samarium'      => 'Sm',
  'Sauerstoff'    => 'O',
  'Scandium'      => 'Sc',
  'Schwefel'      => 'S',
  'Seaborgium'    => 'Sg',
  'Selen'         => 'Se',
  'Silber'        => 'Ag',
  'Silicium'      => 'Si',
  'Stickstoff'    => 'N',
  'Strontium'     => 'Sr',
  'Tantal'        => 'Ta',
  'Technetium'    => 'Tc',
  'Tellur'        => 'Te',
  'Tenness'       => 'Ts',
  'Terbium'       => 'Tb',
  'Thallium'      => 'Tl',
  'Thorium'       => 'Th',
  'Thulium'       => 'Tm',
  'Titan'         => 'Ti',
  'Uran'          => 'U',
  'Vanadium'      => 'V',
  'Wasserstoff'   => 'H',
  'Wolfram'       => 'W',
  'Xenon'         => 'Xe',
  'Ytterbium'     => 'Yb',
  'Yttrium'       => 'Y',
  'Zink'          => 'Zn',
  'Zinn'          => 'Sn',
  'Zirconium'     => 'Zr'
}

Class Method Summary collapse

Class Method Details

.atomgewichte?Boolean

#

ChemistryParadise.atomgewichte?

#

Returns:

  • (Boolean)


21
22
23
24
# File 'lib/chemistry_paradise/toplevel_methods/atomgewichte.rb', line 21

def self.atomgewichte?
  require 'yaml'
  YAML.load_file(Constants::FILE_ATOMGEWICHTE)
end

.atomic_mass_of(i) ⇒ Object

#

ChemistryParadise.atomic_mass_of

This method is a shortcut, to quickly calculate the molecular mass of a compound. See the usage example that follows.

Usage examples:

ChemistryParadise.atomic_mass_of 'C10H13N5O3' # => "251.245"
ChemistryParadise.atomic_mass_of 'H2O'        # => "18.015"
#


525
526
527
# File 'lib/chemistry_paradise/utility_scripts/calculate_atomic_mass.rb', line 525

def self.atomic_mass_of(i)
  ChemistryParadise::CalculateAtomicMass.parse(i)
end

.calculate_atomic_mass_based_on_isotope_percentage(*array) ⇒ Object

#

ChemistryParadise.calculate_atomic_mass_based_on_isotope_percentage

This method accepts as many arguments as the user wants to.

It has to follow a specific format. The first entry must be the “Häufigkeit” and the second entry must be the corresponding atomic mass (“relative_atommasse”).

Usage example:

ChemistryParadise.calculate_atomic_mass_based_on_isotope_percentage(78.99, 23.985, 10.00, 24.985, 11.01, 25.983)
#


130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 130

def self.calculate_atomic_mass_based_on_isotope_percentage(*array)
  round_to_n_positions = 3
  result = 0
  array.map! {|entry| entry.to_s.tr(',','.').to_f }
  entries = array.each_slice(2)
  entries.each {|häufigkeit, relative_atommasse|
    if häufigkeit > 0
      häufigkeit = häufigkeit / 100.0
    end
    zwischenergebnis = relative_atommasse * häufigkeit
    result += zwischenergebnis
  }
  return result.round(round_to_n_positions)
end

.convert_parens(i) ⇒ Object

#

ChemistryParadise.convert_parens

This method will properly convert the () parens that can be found in a chemical formula.

For instance:

Al2(SO4)3

Is effectively the same such as:

Al2SO4SO4SO4
#


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/chemistry_paradise/toplevel_methods/convert_parens.rb', line 24

def self.convert_parens(i)
  if i.is_a? Array
    i.each {|entry| convert_parens(entry) }
  else
    i = i.dup if i.frozen?
    i.tr!('', '1') if i.include? ''
    i.tr!('', '2') if i.include? ''
    i.tr!('', '3') if i.include? ''
    i.tr!('', '4') if i.include? ''
    i.tr!('', '5') if i.include? ''
    i.tr!('', '6') if i.include? ''
    i.tr!('', '7') if i.include? ''
    i.tr!('', '8') if i.include? ''
    i.tr!('', '9') if i.include? ''
    if i.include? '('
      n_parens = i.count('(')
      if n_parens > 1 # Ok, this may be a really complex formula, like:
                      #   Fe(OH)3 + H2SO4 -> Fe2(SO4)3 + H2O
        splitted = i.split(' ')
        splitted = splitted.map {|entry| convert_parens(entry) } # For now we remove some things. 
        return splitted.join(' ')
      else
        regex = /\((.+)\)(\d)([A-Za-z]{0,3}\d{0,3})/ # See: https://rubular.com/r/clShxRBIpzEtlF
        i =~ regex
        i = i[0, i.index('(')]
        i << $1 * $2.to_i # Which group * n repetition
        i << $3.dup if $3
      end
    end
    return i
  end
end

.display_where_the_molmasses_are_keptObject

#

ChemistryParadise.display_where_the_molmasses_are_kept

#


16
17
18
# File 'lib/chemistry_paradise/toplevel_methods/display_where_the_molmasses_are_kept.rb', line 16

def self.display_where_the_molmasses_are_kept
  Colours.e(Constants::FILE_ATOMGEWICHTE)
end

.do_use_englishObject

#

ChemistryParadise.do_use_english

Use this method if you want to use the english language.

#


37
38
39
# File 'lib/chemistry_paradise/toplevel_methods/language.rb', line 37

def self.do_use_english
  set_use_this_language(:english)
end

.do_use_germanObject

#

ChemistryParadise.do_use_german

Use this method if you want to use the german language.

#


46
47
48
# File 'lib/chemistry_paradise/toplevel_methods/language.rb', line 46

def self.do_use_german
  set_use_this_language(:german)
end

.e(i = '') ⇒ Object

#

ChemistryParadise.e

#


12
13
14
# File 'lib/chemistry_paradise/toplevel_methods/e.rb', line 12

def self.e(i = '')
  puts i
end

.embeddable_interfaceObject

#

ChemistryParadise::Wetter.embeddable_interface

This method can be used to “embed” a fake-object that implements the module defined above.

#


72
73
74
75
76
# File 'lib/chemistry_paradise/www/wetter/embeddable_interface.rb', line 72

def self.embeddable_interface
  object = Object.new
  object.extend(ChemistryParadise::Wetter::EmbeddableInterface)
  return object
end

.empirische_formel(i = 'KClO4', round_to_n_decimal_positions = 2) ⇒ Object

#

ChemistryParadise.logempirische_formel

This variant is german.

We will assume 100 g as input.

#


182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 182

def self.empirische_formel(
    i                            = 'KClO4', # 'H2O'
    round_to_n_decimal_positions = 2
  )
  i = i.to_s.strip.dup
  require 'yaml'
  dataset = YAML.load_file(Constants::FILE_ATOMGEWICHTE)
  # ======================================================================= #
  # So, 100 g H2O here.
  # ======================================================================= #
  array = SplitMoleculeNames.new(i).result
  hash = {} # Store the mol here.
  result = {}
  # ======================================================================= #
  # array may look like this: ["H2", "O"]
  # ======================================================================= #
  array.each {|entry|
    n_times = 1
    if entry =~ /\d+/ # At the least one number.
      n_times = entry.scan(/\d+/).flatten.first.to_i
      # =================================================================== #
      # Now remove the number.
      # =================================================================== #
      entry.gsub!(/\d+/,'')
    end
    key = dataset[entry]
    molmass = key * n_times
    hash[entry] = molmass
  }
  total_mass = hash.values.sum
  hash.each_pair {|key, value|
    new_value = (100.0 / total_mass) * value
    if round_to_n_decimal_positions
      new_value = new_value.round(round_to_n_decimal_positions)
    end
    result[key] = new_value
  }
  return result
end

.file_atomgewichteObject

#

ChemistryParadise.file_atomgewichte

#


14
15
16
# File 'lib/chemistry_paradise/toplevel_methods/atomgewichte.rb', line 14

def self.file_atomgewichte
  Constants::FILE_ATOMGEWICHTE
end

.is_on_roebe?Boolean

#

ChemistryParadise.is_on_roebe?

#

Returns:

  • (Boolean)


12
13
14
# File 'lib/chemistry_paradise/toplevel_methods/roebe.rb', line 12

def self.is_on_roebe?
  ENV['IS_ROEBE'].to_s == '1'
end

.kelvin(n_celsius) ⇒ Object

#

ChemistryParadise.kelvin

This method will output how many Kelvin n Celsius are.

The temperature T in Kelvin (K) is equal to the temperature T in degrees Celsius (°C) plus 273.1.

The formula thus is:

T(K) = T(°C) + 273.15
#


22
23
24
25
26
27
28
# File 'lib/chemistry_paradise/toplevel_methods/kelvin.rb', line 22

def self.kelvin(n_celsius)
  if n_celsius.is_a? Array
    n_celsius = n_celsius.first
  end
  n_kelvin = n_celsius.to_f + 273.15
  return n_kelvin
end

.log(of) ⇒ Object

#

ChemistryParadise.log

Calculate the log of something.

#


169
170
171
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 169

def self.log(of)
  return Math.log10(of)
end

.periodic_table?Boolean

#

ChemistryParadise.periodic_table?

#

Returns:

  • (Boolean)


12
13
14
# File 'lib/chemistry_paradise/toplevel_methods/periodic_table.rb', line 12

def self.periodic_table?
  '/Users/x/DATA/SCIENCE/YAML/periodic_table.yml'
end

.project_base_directory?Boolean

#

ChemistryParadise.project_base_directory?

#

Returns:

  • (Boolean)


20
21
22
# File 'lib/chemistry_paradise/project/project.rb', line 20

def self.project_base_directory?
  PROJECT_BASE_DIRECTORY
end

.remove_this_molecule_from(this_molecule = 'OH', from = 'C2H5NO2') ⇒ Object

#

ChemistryParadise.remove_this_molecule_from

The first argument is the molecule that should be deducted from the formula.

#


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/chemistry_paradise/toplevel_methods/remove_this_molecule_from.rb', line 17

def self.remove_this_molecule_from(
    this_molecule = 'OH',
    from          = 'C2H5NO2'
  )
  array_big_molecule  = ::ChemistryParadise.split_this_molecular_formula_into_a_hash(from)
  array_this_molecule = ::ChemistryParadise.split_this_molecular_formula_into_a_hash(this_molecule)
  # ======================================================================= #
  # Next, iterate over the small molecule.
  # ======================================================================= #
  array_this_molecule.each {|this_compound|
    unless this_compound =~ /\d+/
      this_compound << '1' # Must be at the least one.
    end
    # ===================================================================== #
    # Select the entry that is the correct one.
    # ===================================================================== #
    this_entry = array_big_molecule.find {|entry|
      entry[0,1] == this_compound[0,1]
    }
    begin
      n_times_in_the_big_molecule   = /(\d{1,3})/.match(this_entry)[1].to_i
      n_times_in_the_small_molecule = /(\d{1,3})/.match(this_compound)[1].to_i
      new_n_times = n_times_in_the_big_molecule - n_times_in_the_small_molecule
      new_entry = this_compound[0,1]+new_n_times.to_s
      # ===================================================================== #
      # Now we have the new entry; we need to re-insert it into the big
      # original Array.
      # ===================================================================== #
      proper_index = array_big_molecule.index {|entry|
        entry[0,1] == this_compound[0,1]
      }
      array_big_molecule[proper_index] = new_entry
    rescue NoMethodError => error
      pp error
    end
  }
  return array_big_molecule.join # Join it up again.
end

.return_element_symbol_from_this_german_name(i) ⇒ Object

#

ChemistryParadise.return_element_symbol_from_this_german_name

#


142
143
144
145
146
147
148
149
150
# File 'lib/chemistry_paradise/constants/german_names_of_elements_to_element_symbol.rb', line 142

def self.return_element_symbol_from_this_german_name(i)
  i = i.dup if i.frozen?
  i.capitalize!
  if GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL.has_key? i
    GERMAN_NAMES_OF_ELEMENTS_TO_ELEMENT_SYMBOL[i]
  else
    nil
  end
end

.row1Object

#

ChemistryParadise.row1

Return the first row of the periodic table.

#


14
15
16
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 14

def self.row1
  return %w( H He )
end

.row2Object

#

ChemistryParadise.row2

Return the second row of the periodic table.

#


23
24
25
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 23

def self.row2
  return %w( Li Be B C N O F Ne )
end

.row3Object

#

ChemistryParadise.row3

Return the third row of the periodic table.

#


32
33
34
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 32

def self.row3
  return %w( Na Mg Al Si P S Cl Ar )
end

.row4Object

#

ChemistryParadise.row4

Return the fourth row of the periodic table.

#


41
42
43
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 41

def self.row4
  return %w( K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr )
end

.row5Object

#

ChemistryParadise.row5

Return the fifth row of the periodic table.

#


50
51
52
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 50

def self.row5
  return %w( Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe )
end

.row6Object

#

ChemistryParadise.row6

Return the sixth row of the periodic table.

#


59
60
61
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 59

def self.row6
  return %w( Cs Ba Lu Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn )
end

.row7Object

#

ChemistryParadise.row7

Return the seventh row of the periodic table.

#


68
69
70
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 68

def self.row7
  return %w( Fr Ra Lr Rf Db Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og )
end

.row8Object

#

ChemistryParadise.row8

This is not a real row - just a helper row.

#


77
78
79
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 77

def self.row8
  return %w( La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb )
end

.row9Object

#

ChemistryParadise.row9

This is not a real row - just a helper row.

#


86
87
88
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 86

def self.row9
  return %w( Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No )
end

.sanitize(i) ⇒ Object

#

ChemistryParadise.sanitize

Usage example:

ChemistryParadise.sanitize('C6H13N3O3') # => "C₆H₁₃N₃O₃"
#


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 98

def self.sanitize(i)
  if i.is_a? Array
    i = i.first
  end
  i = i.dup
  i.gsub!(/1/, '')
  i.gsub!(/2/, '')
  i.gsub!(/3/, '')
  i.gsub!(/4/, '')
  i.gsub!(/5/, '')
  i.gsub!(/6/, '')
  i.gsub!(/7/, '')
  i.gsub!(/8/, '')
  i.gsub!(/9/, '')
  i.gsub!(/0/, '')
  return i
end

.set_use_this_language(i = :german) ⇒ Object

#

ChemistryParadise.set_use_this_language

#


21
22
23
# File 'lib/chemistry_paradise/toplevel_methods/language.rb', line 21

def self.set_use_this_language(i = :german)
  @use_this_language = i
end

.show_electron_negativity_chartObject

#

ChemistryParadise.show_electron_negativity_chart

#


14
15
16
17
18
19
20
# File 'lib/chemistry_paradise/toplevel_methods/show_electron_negativity_chart.rb', line 14

def self.show_electron_negativity_chart
  Constants::ELECTRON_NEGATIVITY_CHART.each_pair {|key, value|
    value = value.to_f
    value = '%.2f' % value 
    puts key.ljust(2)+' -> '+value.to_s.rjust(2)
  }
end

.simplified_current_degreesObject

#

ChemistryParadise.simplified_current_degrees

#


524
525
526
# File 'lib/chemistry_paradise/wetter/wetter.rb', line 524

def self.simplified_current_degrees
  ChemistryParadise::Wetter.simplified_current_degrees
end

.split_this_molecular_formula_into_a_hash(i) ⇒ Object

#

ChemistryParadise.split_this_molecular_formula_into_a_hash

#


198
199
200
201
# File 'lib/chemistry_paradise/split_molecule_names.rb', line 198

def self.split_this_molecular_formula_into_a_hash(i)
  i = i.first if i.is_a? Array
  SplitMoleculeNames.new(i).result
end

.start_sinatra_interfaceObject

#

ChemistryParadise.start_sinatra_interface

#


122
123
124
125
# File 'lib/chemistry_paradise/sinatra/sinatra.rb', line 122

def self.start_sinatra_interface
  puts 'Trying to start the sinatra-interface of ChemistryParadise next.'
  ::ChemistryParadise::Sinatra.run!
end

.torr_to_bar(i = 720) ⇒ Object

#

ChemistryParadise.torr_to_bar

This method can be used to convert n Torr into n bar.

The first argument is “n Torr”.

The result will be in “n bar”.

#


154
155
156
157
158
159
160
161
162
# File 'lib/chemistry_paradise/toplevel_methods/misc.rb', line 154

def self.torr_to_bar(i = 720)
  if i.is_a? Array
    i = i.first
  end
  result = i.to_f * (1.013 / 760)
  rounded_result = result.round(3)
  beautified_result = '%.3f' % rounded_result 
  return beautified_result
end

.use_which_language?Boolean

#

ChemistryParadise.use_which_language?

#

Returns:

  • (Boolean)


28
29
30
# File 'lib/chemistry_paradise/toplevel_methods/language.rb', line 28

def self.use_which_language?
  @use_this_language
end