struct Quartz::Any

Overview

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.

Defined in:

quartz/any.cr

Constructors

Instance Method Summary

Instance methods inherited from struct Value

==(other : Quartz::Any) ==

Instance methods inherited from class Object

===(other : Quartz::Any) ===

Constructor Detail

def self.array(initial_capacity : Int = 0) : self #

Creates a Any value that wraps a new Array


[View source]
def self.build_array(initial_capacity : Int = 0, &) : self #

[View source]
def self.build_hash(default_block : Hash(K, V), K -> V | Nil = nil, initial_capacity = nil, &) : self #

[View source]
def self.hash(default_block : Hash(K, V), K -> V | Nil = nil, initial_capacity = nil) : self #

Creates a Any value that wraps a new Hash


[View source]
def self.new(raw : Type) #

Creates a Any value that wraps the given value.


[View source]

Instance Method Detail

def <<(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.


[View source]
def <<(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.


[View source]
def ==(other : Quartz::Any) #

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


[View source]
def ==(other) #

Returns true if the raw object is equal to other.


[View source]
def [](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.


[View source]
def [](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.


[View source]
def []=(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.


[View source]
def []=(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.


[View source]
def []=(key : Any, value : Any) : Any #

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


[View source]
def []=(key : Any, value : Any::Type) : Any #

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


[View source]
def []=(key : Any::Type, value : Any::Type) : Any #

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


[View source]
def []?(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.


[View source]
def []?(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.


[View source]
def []?(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.


[View source]
def as_a : Array(Any) #

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


[View source]
def as_a? : Array(Any) | Nil #

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


[View source]
def as_bool : Bool #

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


[View source]
def as_bool? : Bool | Nil #

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


[View source]
def as_c : Char #

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


[View source]
def as_c? : Char | Nil #

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


[View source]
def as_f : Float64 #

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


[View source]
def as_f32 : Float32 #

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


[View source]
def as_f32? : Float32 | Nil #

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


[View source]
def as_f64 : Float64 #

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


[View source]
def as_f64? : Float64 | Nil #

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


[View source]
def as_f? : Float64 | Nil #

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


[View source]
def as_h : Hash(Any, Any) #

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


[View source]
def as_h? : Hash(Any, Any) | Nil #

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


[View source]
def as_i : Int32 #

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


[View source]
def as_i128 : Int128 #

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


[View source]
def as_i128? : Int128 | Nil #

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


[View source]
def as_i16 : Int16 #

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


[View source]
def as_i16? : Int16 | Nil #

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


[View source]
def as_i32 : Int32 #

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


[View source]
def as_i32? : Int32 | Nil #

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


[View source]
def as_i64 : Int64 #

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


[View source]
def as_i64? : Int64 | Nil #

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


[View source]
def as_i8 : Int8 #

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


[View source]
def as_i8? : Int8 | Nil #

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


[View source]
def as_i? : Int32 | Nil #

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


[View source]
def as_nil : Nil #

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


[View source]
def as_s : String #

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


[View source]
def as_s? : String | Nil #

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


[View source]
def as_sym : Symbol #

[View source]
def as_sym? : Symbol | Nil #

[View source]
def as_u128 : UInt64 #

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


[View source]
def as_u128? : UInt64 | Nil #

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


[View source]
def as_u16 : UInt16 #

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


[View source]
def as_u16? : UInt16 | Nil #

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


[View source]
def as_u32 : UInt32 #

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


[View source]
def as_u32? : UInt32 | Nil #

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


[View source]
def as_u64 : UInt64 #

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


[View source]
def as_u64? : UInt64 | Nil #

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


[View source]
def as_u8 : UInt8 #

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


[View source]
def as_u8? : UInt8 | Nil #

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


[View source]
def hash(hasher) #

See Object#hash(hasher)


[View source]
def raw : Type #

Returns the raw underlying value.


[View source]
def size : Int #

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


[View source]