struct

TOML::Any

Inherits Struct / Value / Object

TOML::Any is a convenient wrapper around all possible TOML types (TOML::Any::Type) and can be used for traversing dynamic or unknown TOML structures.

Aka it's the same as what JSON::Any, and YAML::Any does but for TOML.

Constructors

new(raw : Type)
Source

Instance methods

==(other : TOML::Any)

Returns true if both self and other's raw object are equal.

Source
==(other)

Returns true if the raw object is equal to other.

Source
[](index : Int) : TOML::Any

Assumes the underlying value is an Array and returns the element at the given index. Raises if the underlying value is not an Array.

Source
[](key : String) : TOML::Any

Assumes the underlying value is a Hash and returns the element with the given key. Raises if the underlying value is not a Hash.

Source
[]?(index : Int) : TOML::Any | Nil

Assumes the underlying value is an Array and returns the element at the given index, or nil if out of bounds. Raises if the underlying value is not an Array.

Source
[]?(key : String) : TOML::Any | Nil

Assumes the underlying value is a Hash and returns the element with the given key, or nil if the key is not present. Raises if the underlying value is not a Hash.

Source
as_a

Checks that the underlying value is Array, and returns its value. Raises otherwise.

Source
as_a?

Checks that the underlying value is Array, and returns its value. Returns nil otherwise.

Source
as_bool

Checks that the underlying value is Bool, and returns its value. Raises otherwise.

Source
as_bool?

Checks that the underlying value is Bool, and returns its value. Returns nil otherwise.

Source
as_f

Checks that the underlying value is Float, and returns its value as an Float64. Raises otherwise.

Source
as_f32

Checks that the underlying value is Float, and returns its value as an Float32. Raises otherwise.

Source
as_f32?

Checks that the underlying value is Float, and returns its value as an Float32. Returns nil otherwise.

Source
as_f?

Checks that the underlying value is Float, and returns its value as an Float64. Returns nil otherwise.

Source
as_h

Checks that the underlying value is Hash, and returns its value. Raises otherwise.

Source
as_h?

Checks that the underlying value is Hash, and returns its value. Returns nil otherwise.

Source
as_i

Checks that the underlying value is Int, and returns its value as an Int32. Raises otherwise.

Source
as_i64

Checks that the underlying value is Int, and returns its value as an Int64. Raises otherwise.

Source
as_i64?

Checks that the underlying value is Int, and returns its value as an Int64. Returns nil otherwise.

Source
as_i?

Checks that the underlying value is Int, and returns its value as an Int32. Returns nil otherwise.

Source
as_nil

Checks that the underlying value is Nil, and returns nil. Raises otherwise.

Source
as_s

Checks that the underlying value is String, and returns its value. Raises otherwise.

Source
as_s?

Checks that the underlying value is String, and returns its value. Returns nil otherwise.

Source
as_time

Checks that the underlying value is Time, and returns its value. Raises otherwise.

Source
as_time?

Checks that the underlying value is Time, and returns its value. Returns nil otherwise.

Source
as_time_span

Checks that the underlying value is Time::Span, and returns its value. Raises otherwise.

Source
as_time_span?

Checks that the underlying value is Time::Span, and returns its value. Returns nil otherwise.

Source
clone

Returns a new TOML::Any instance with the raw value cloneed.

Source
dig(index_or_key : String | Int, *subkeys) : TOML::Any

Traverses the depth of a structure and returns the value, otherwise raises.

Source
dig?(index_or_key : String | Int, *subkeys) : TOML::Any | Nil

Traverses the depth of a structure and returns the value. Returns nil if not found.

Source
dup

Returns a new TOML::Any instance with the raw value duped.

Source
hash(hasher)

See Object#hash(hasher)

Source
raw

Returns the raw underlying value.

Source
size

Assume the underlying toml value is an Array or a Hash and returns its size raises when the underlying value is not an Array or Hash

Source

Nested types