class ChemistryParadise::ParseCommandline

Public Class Methods

new( optional_input = ARGV, run_already = true ) click to toggle source
#

initialize

#
# File lib/chemistry_paradise/commandline/parse_commandline.rb, line 22
def initialize(
    optional_input = ARGV,
    run_already    = true
  )
  set_commandline(optional_input)
  reset
  run if run_already
end

Public Instance Methods

berechne_atomgewicht(i) click to toggle source
#

berechne_atomgewicht

#
# File lib/chemistry_paradise/commandline/parse_commandline.rb, line 68
def berechne_atomgewicht(i)
  pp i
  if i.is_a? Array
    i.flatten.each {|entry|
      berechne_atomgewicht(i)
    }
  else
    if i == :test_default_molecules
      i = ARRAY_TEST_THESE_MOLECULES
    end
    if i.is_a? Array
      berechne_atomgewicht(i)
    else
      e sprintf(
        'The mass number of %-4s is %3s',
        i,
        ChemistryParadise::CalculateAtomicMass.new(i).result.to_s
      )
    end
  end
end
check_against_menu( i = @commandline )
Alias for: menu
menu( i = @commandline ) click to toggle source
#

menu (menu tag)

#
Also aliased as: check_against_menu
reset() click to toggle source
#

reset

#
Calls superclass method ChemistryParadise::Base#reset
# File lib/chemistry_paradise/commandline/parse_commandline.rb, line 34
def reset
  super()
end
run() click to toggle source
#

run

#
# File lib/chemistry_paradise/commandline/parse_commandline.rb, line 61
def run
  menu
end
set_commandline(i) click to toggle source
#

set_commandline

#
# File lib/chemistry_paradise/commandline/parse_commandline.rb, line 53
def set_commandline(i)
  i = [i] unless i.is_a? Array
  @commandline = i
end
show_help() click to toggle source
#

show_help

The help options can be queried via:

chemistry_paradise --help
#
# File lib/chemistry_paradise/commandline/help.rb, line 17
def show_help
  e 'The following options are documented:'
  e
  e '  --molmassen?                     # show '\
    'where the molmasses are kept (a file)'
  e '  --electronegativity-of=F/Fe      # report '\
    'the electronegativitiy of the elements F '\
    'and Fe (Fluor and Iron)'
  e '  --show_electron_negativity_chart # show '\
    'the electron negativity chart of the atoms'
  e '  /Quecksilber/                    # use '\
    'a pseudo-regex to obtain the element-symbol '\
    'from a german name'
  e '  ^^^ the above // is called a pseudo-regex; pseudo '\
    'because it is actually a String and not a regex'
  e
end
show_the_periodic_table() click to toggle source
#

show_the_periodic_table

#
# File lib/chemistry_paradise/commandline/parse_commandline.rb, line 41
def show_the_periodic_table
  _ = ::ChemistryParadise.periodic_table?
  if File.exist? _
    YAML.load_file(_).each_pair {|key, value|
      e '  '+(key.to_s+ ':').ljust(3)+' '+value.to_s.rjust(2)
    }
  end
end