Class PSON::Pure::Generator::State
In: lib/puppet/external/pson/pure/generator.rb
Parent: Object

This class is used to create State instances, that are use to hold data while generating a PSON text from a a Ruby data structure.

Methods

Attributes

array_nl  [RW]  This string is put at the end of a line that holds a PSON array.
indent  [RW]  This string is used to indent levels in the PSON text.
max_nesting  [RW]  This integer returns the maximum level of data structure nesting in the generated PSON, max_nesting = 0 if no maximum is checked.
object_nl  [RW]  This string is put at the end of a line that holds a PSON object (or Hash).
space  [RW]  This string is used to insert a space between the tokens in a PSON string.
space_before  [RW]  This string is used to insert a space before the ’:’ in PSON objects.

Public Class methods

Creates a State object from opts, which ought to be Hash to create a new State instance configured by opts, something else to create an unconfigured instance. If opts is a State object, it is just returned.

Instantiates a new State object, configured by opts.

opts can have the following keys:

  • indent: a string used to indent levels (default: ’’),
  • space: a string that is put after, a : or , delimiter (default: ’’),
  • space_before: a string that is put before a : pair delimiter (default: ’’),
  • object_nl: a string that is put at the end of a PSON object (default: ’’),
  • array_nl: a string that is put at the end of a PSON array (default: ’’),
  • check_circular: true if checking for circular data structures should be done (the default), false otherwise.
  • check_circular: true if checking for circular data structures should be done, false (the default) otherwise.
  • allow_nan: true if NaN, Infinity, and -Infinity should be generated, otherwise an exception is thrown, if these values are encountered. This options defaults to false.

Public Instance methods

Returns true if NaN, Infinity, and -Infinity should be considered as valid PSON and output.

Returns true, if circular data structures should be checked, otherwise returns false.

Configure this State instance with the Hash opts, and return itself.

Forget object for this generating run.

Remember object, to find out if it was already encountered (if a cyclic data structure is if a cyclic data structure is rendered).

Returns true, if object was already seen during this generating run.

Returns the configuration instance variables as a hash, that can be passed to the configure method.

[Validate]