Class | JSON::Ext::Generator::State
In: | ext/json/ext/generator/generator.c
Parent: | Object

### Methods

[] [] allow_nan? allow_nan? array_nl array_nl array_nl= array_nl= ascii_only? ascii_only? buffer_initial_length buffer_initial_length buffer_initial_length= buffer_initial_length= check_circular? check_circular? configure configure depth depth depth= depth= from_state from_state generate generate indent indent indent= indent= initialize_copy initialize_copy max_nesting max_nesting max_nesting= max_nesting= merge merge new new object_nl object_nl object_nl= object_nl= quirks_mode quirks_mode quirks_mode= quirks_mode= quirks_mode? quirks_mode? space space space= space= space_before space_before space_before= space_before= to_h to_h

### Public Class methods

from_state(opts)

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.

from_state(opts)

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.

new(opts = {})

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 JSON object (default: ’’),
- array_nl: a string that is put at the end of a JSON array (default: ’’),
- 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.
- quirks_mode: Enables quirks_mode for parser, that is for example generating single JSON values instead of documents is possible.
- buffer_initial_length: sets the initial length of the generator‘s internal buffer.

new(opts = {})

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 JSON object (default: ’’),
- array_nl: a string that is put at the end of a JSON array (default: ’’),
- 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.
- quirks_mode: Enables quirks_mode for parser, that is for example generating single JSON values instead of documents is possible.
- buffer_initial_length: sets the initial length of the generator‘s internal buffer.

### Public Instance methods

[](name)

Return the value returned by method `name`.

[](name)

Return the value returned by method `name`.

allow_nan?

Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.

allow_nan?

Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.

array_nl()

This string is put at the end of a line that holds a JSON array.

array_nl()

This string is put at the end of a line that holds a JSON array.

array_nl=(array_nl)

This string is put at the end of a line that holds a JSON array.

array_nl=(array_nl)

This string is put at the end of a line that holds a JSON array.

ascii_only?

Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.

ascii_only?

Returns true, if NaN, Infinity, and -Infinity should be generated, otherwise returns false.

buffer_initial_length

This integer returns the current inital length of the buffer.

buffer_initial_length

This integer returns the current inital length of the buffer.

buffer_initial_length=(length)

This sets the initial length of the buffer to `length`, if `length` > 0, otherwise its value isn‘t changed.

buffer_initial_length=(length)

This sets the initial length of the buffer to `length`, if `length` > 0, otherwise its value isn‘t changed.

check_circular?

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

check_circular?

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

configure(opts)

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

configure(opts)

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

depth

This integer returns the current depth of data structure nesting.

depth

This integer returns the current depth of data structure nesting.

depth=(depth)

This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked.

depth=(depth)

This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked.

generate(obj)

Generates a valid JSON document from object `obj` and returns the result. If no valid JSON document can be created this method raises a GeneratorError exception.

generate(obj)

Generates a valid JSON document from object `obj` and returns the result. If no valid JSON document can be created this method raises a GeneratorError exception.

indent()

This string is used to indent levels in the JSON text.

indent()

This string is used to indent levels in the JSON text.

indent=(indent)

This string is used to indent levels in the JSON text.

indent=(indent)

This string is used to indent levels in the JSON text.

initialize_copy(orig)

Initializes this object from orig if it to be duplicated/cloned and returns it.

initialize_copy(orig)

Initializes this object from orig if it to be duplicated/cloned and returns it.

max_nesting

This integer returns the maximum level of data structure nesting in the generated JSON, max_nesting = 0 if no maximum is checked.

max_nesting

This integer returns the maximum level of data structure nesting in the generated JSON, max_nesting = 0 if no maximum is checked.

max_nesting=(depth)

This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked.

max_nesting=(depth)

This sets the maximum level of data structure nesting in the generated JSON to the integer depth, max_nesting = 0 if no maximum should be checked.

merge(p1)

Alias for configure

merge(p1)

Alias for configure

object_nl()

This string is put at the end of a line that holds a JSON object (or Hash).

object_nl()

This string is put at the end of a line that holds a JSON object (or Hash).

object_nl=(object_nl)

This string is put at the end of a line that holds a JSON object (or Hash).

object_nl=(object_nl)

This string is put at the end of a line that holds a JSON object (or Hash).

quirks_mode?

Returns true, if quirks mode is enabled. Otherwise returns false.

quirks_mode?

Returns true, if quirks mode is enabled. Otherwise returns false.

quirks_mode=(enable)

If set to true, enables the quirks_mode mode.

quirks_mode=(enable)

If set to true, enables the quirks_mode mode.

quirks_mode?

Returns true, if quirks mode is enabled. Otherwise returns false.

quirks_mode?

Returns true, if quirks mode is enabled. Otherwise returns false.

space()

This string is used to insert a space between the tokens in a JSON string.

space()

This string is used to insert a space between the tokens in a JSON string.

space=(space)

This string is used to insert a space between the tokens in a JSON string.

space=(space)

This string is used to insert a space between the tokens in a JSON string.

space_before()

This string is used to insert a space before the ’:’ in JSON objects.

space_before()

This string is used to insert a space before the ’:’ in JSON objects.

space_before=(space_before)

This string is used to insert a space before the ’:’ in JSON objects.

space_before=(space_before)

This string is used to insert a space before the ’:’ in JSON objects.

to_h

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

to_h

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

[Validate]