struct

Quartz::Any

Inherits Struct / Value / Object

Any is a convenient wrapper around all possible Quartz types (Any::Type). It is used to denote all types that may be transmitted between two Ports through couplings.

Any is used internally to store the outputs generated by atomic models before presenting them to their receivers.

Constructors

array(initial_capacity : Int = 0) : self

Creates a Any value that wraps a new Array

Source
build_array(initial_capacity : Int = 0, &) : self
Source
build_hash(default_block : Hash(K, V), K -> V | Nil = nil, initial_capacity = nil, &) : self
Source
hash(default_block : Hash(K, V), K -> V | Nil = nil, initial_capacity = nil) : self

Creates a Any value that wraps a new Hash

Source
new(raw : Type)

Creates a Any value that wraps the given value.

Source

Instance methods

<<(value : Any) : Any

Assumes the underlying value is a Array and appends the given value at the end of the array. Raises if the underlying value is not an Array.

Source
<<(value : Any::Type) : Any

Assumes the underlying value is a Array and appends the given value at the end of the array. Raises if the underlying value is not an Array.

Source
==(other : Quartz::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
[](key : Any) : 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
[](key : Any::Type) : Any

Assumes the underlying value is a Hash or Array and returns the element with the given index or key.

Raises if the underlying value is not a Hash or Array.

Source
[]=(index : Int, value : Any) : Any

Assumes the underlying value is a Array and sets the given value at the given index. Raises if the underlying value is not an Array.

Source
[]=(index : Int, value : Any::Type) : Any

Assumes the underlying value is a Array and sets the given value at the given index. Raises if the underlying value is not an Array.

Source
[]=(key : Any, value : Any) : Any

Assumes the underlying value is a Hash and sets the given value at the given key.

Source
[]=(key : Any, value : Any::Type) : Any

Assumes the underlying value is a Hash and sets the given value at the given key.

Source
[]=(key : Any::Type, value : Any::Type) : Any

Assumes the underlying value is a Hash and sets the given value at the given key.

Source
[]?(index : Int) : 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 : Any::Type) : Any | Nil

Assumes the underlying value is a Hash or Array and returns the element with the given index or key.

Raises if the underlying value is not a Hash or Array.

Source
[]?(key : Any) : Any

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_c

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

Source
as_c?

Checks that the underlying value is Char, 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_f64

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

Source
as_f64?

Checks that the underlying value is Float, and returns its value as an Float64. 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_i128

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

Source
as_i128?

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

Source
as_i16

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

Source
as_i16?

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

Source
as_i32

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

Source
as_i32?

Checks that the underlying value is Int, and returns its value as an Int32. Returns nil 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_i8

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

Source
as_i8?

Checks that the underlying value is Int, and returns its value as an Int8. 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_sym
Source
as_sym?
Source
as_u128

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

Source
as_u128?

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

Source
as_u16

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

Source
as_u16?

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

Source
as_u32

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

Source
as_u32?

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

Source
as_u64

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

Source
as_u64?

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

Source
as_u8

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

Source
as_u8?

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

Source
hash(hasher)

See Object#hash(hasher)

Source
raw

Returns the raw underlying value.

Source
size

Assumes the underlying value is an Array or Hash and returns its size. Raises if the underlying value is not an Array or Hash.

Source

Nested types