This is the data structure that stores all the keywords specifiing the job. Internaly, it uses Hash for the storage, but it should not be accessed directly. The indexes are Symbols, when the settings are read from hash or file, string indexes are converted to symbols (and lowercase).

There is a list of possible keywords stored in YAML file with adittional info on the keyword, such as type and default value.

When the Settings structure is build from a Hash (that can be read from YAML file), every keyword is checked against the keyword list. Unknown keyword raises an error, so does keyword that has apparently wrong type.

When a keyword is looked up using the [] method and the keyword is missing, action specified in the keyword database is performed. The options are:

When default value is used, it is written into the settings as well. It means each warning is printed only once, and the complete settings can be printed out at the end of the job.

The settings can have multiple levels, but only the root level is used by the actual calculations. Subsections of deeper levels can be used to store settings for different parts of the job, but must be copied to the root level before the calculation is performed.

class SettingsKeyword

One record used of the keywords database - there it is indexed by the keyword name.

class Settings

Settings.fix_keyword   Settings.from_file   []   []=   check_unknown_keywords   copy_subsection_to_root   exists?   fix_values   from_hash   from_yaml_file   initialize   key_to_symbol   set?  

Initialize

initialize

Settings.from_file(filename)

Access

[](*args)

Read from the settings. Allows any depth of subsections, from root level:

settings[:keyword]

deeper into the subsection tree:

settings[:subsection, :subsubsection, ..., :keyword]

Behaviour when keyword is not found is described above.

exists?(*args) # => boolean

checks if requested keyword is present in settings

set?(*args)

[]=(*args)

Write to the settings - syntax similar to [] . Subsections are created when do not exist.

settings[:subsection, :keyword] = value

copy_subsection_to_root(*args)

Save/load

from_hash(hash)

Constructs the Settings data stucture from Hash, converting the keys to lowercase symbols and checking the values as described above

from_yaml_file(filename)

Loads settings from YAML file (where it should be stored as a Hash) using all the fixes in from_hash

Class methods

Settings.fix_keyword(key,value)

Private methods

key_to_symbol(hash) #=> Hash

Builds symbol-indexed hash from string or symbol -indexed one. All keys are made lowercase.

fix_values(hash)

Traverses recursively hash of keywords and calls Settings.fix_keyword on each value

check_unknown_keywords(hash)