Query a YAML object for a certain parameter.

Description

If the object has the param, then return it. If the param is unknown, create it with the given default value and return the default.

Fields

yamlObj

A Yaml object as created by yaml.load

Methods

getYAML(param_name, default)

Query this YAML object for a certain parameter and return its value. If it does not exist it is created with a default value.

setYAML(param_name, value)

Set a YAML parameter to a certain value. Overwrites the old value or creates a new entry if hithero unknown.

writeYAML(filename)

Write YAML config (including some documentation) to a YAML file. Returns TRUE on success (always), unless writing the file generates an error.

Examples

1
2
3
4
5
6
    yc = YAMLClass$new(list())
    val = yc$getYAML("cat$subCat", "someDefault")
    val  ## someDefault
    val = yc$setYAML("cat$subCat", "someValue")
    val  ## someValue
    yc$getYAML("cat$subCat", "someDefault") ## still 'someValue' (since its set already)

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.