struct Quartz::Any
- Quartz::Any
- Struct
- Value
- Object
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 Port
s
through couplings.
Any
is used internally to store the outputs generated by atomic models
before presenting them to their receivers.
Defined in:
quartz/any.crConstructors
-
.array(initial_capacity : Int = 0) : self
Creates a
Any
value that wraps a newArray
- .build_array(initial_capacity : Int = 0, &) : self
- .build_hash(default_block : Hash(K, V), K -> V? = nil, initial_capacity = nil, &) : self
-
.hash(default_block : Hash(K, V), K -> V? = nil, initial_capacity = nil) : self
Creates a
Any
value that wraps a newHash
-
.new(raw : Type)
Creates a
Any
value that wraps the given value.
Instance Method Summary
-
#<<(value : Any) : Any
Assumes the underlying value is a
Array
and appends the given value at the end of the array. -
#<<(value : Any::Type) : Any
Assumes the underlying value is a
Array
and appends the given value at the end of the array. -
#==(other)
Returns true if the raw object is equal to other.
-
#==(other : Quartz::Any)
Returns true if both
self
and other's raw object are equal. -
#[](key : Any) : Any
Assumes the underlying value is a
Hash
and returns the element with the given key. -
#[](key : Any::Type) : Any
Assumes the underlying value is a
Hash
orArray
and returns the element with the given index or key. -
#[]=(key : Any, value : Any) : Any
Assumes the underlying value is a
Hash
and sets the given value at the given key. -
#[]=(index : Int, value : Any) : Any
Assumes the underlying value is a
Array
and sets the given value at the given index. -
#[]=(index : Int, value : Any::Type) : Any
Assumes the underlying value is a
Array
and sets the given value at the given index. -
#[]=(key : Any, value : Any::Type) : Any
Assumes the underlying value is a
Hash
and sets the given value at the given key. -
#[]=(key : Any::Type, value : Any::Type) : Any
Assumes the underlying value is a
Hash
and sets the given value at the given key. -
#[]?(index : Int) : Any?
Assumes the underlying value is an
Array
and returns the element at the given index, ornil
if out of bounds. -
#[]?(key : Any::Type) : Any?
Assumes the underlying value is a
Hash
orArray
and returns the element with the given index or key. -
#[]?(key : Any) : Any
Assumes the underlying value is a
Hash
and returns the element with the given key, ornil
if the key is not present. -
#as_a : Array(Any)
Checks that the underlying value is
Array
, and returns its value. -
#as_a? : Array(Any)?
Checks that the underlying value is
Array
, and returns its value. -
#as_bool : Bool
Checks that the underlying value is
Bool
, and returns its value. -
#as_bool? : Bool?
Checks that the underlying value is
Bool
, and returns its value. -
#as_c : Char
Checks that the underlying value is
Char
, and returns its value. -
#as_c? : Char?
Checks that the underlying value is
Char
, and returns its value. -
#as_f : Float64
Checks that the underlying value is
Float
, and returns its value as anFloat64
. -
#as_f32 : Float32
Checks that the underlying value is
Float
, and returns its value as anFloat32
. -
#as_f32? : Float32?
Checks that the underlying value is
Float
, and returns its value as anFloat32
. -
#as_f64 : Float64
Checks that the underlying value is
Float
, and returns its value as anFloat64
. -
#as_f64? : Float64?
Checks that the underlying value is
Float
, and returns its value as anFloat64
. -
#as_f? : Float64?
Checks that the underlying value is
Float
, and returns its value as anFloat64
. -
#as_h : Hash(Any, Any)
Checks that the underlying value is
Hash
, and returns its value. -
#as_h? : Hash(Any, Any)?
Checks that the underlying value is
Hash
, and returns its value. -
#as_i : Int32
Checks that the underlying value is
Int
, and returns its value as anInt32
. -
#as_i128 : Int128
Checks that the underlying value is
Int
, and returns its value as anInt128
. -
#as_i128? : Int128?
Checks that the underlying value is
Int
, and returns its value as anInt128
. -
#as_i16 : Int16
Checks that the underlying value is
Int
, and returns its value as anInt16
. -
#as_i16? : Int16?
Checks that the underlying value is
Int
, and returns its value as anInt16
. -
#as_i32 : Int32
Checks that the underlying value is
Int
, and returns its value as anInt32
. -
#as_i32? : Int32?
Checks that the underlying value is
Int
, and returns its value as anInt32
. -
#as_i64 : Int64
Checks that the underlying value is
Int
, and returns its value as anInt64
. -
#as_i64? : Int64?
Checks that the underlying value is
Int
, and returns its value as anInt64
. -
#as_i8 : Int8
Checks that the underlying value is
Int
, and returns its value as anInt8
. -
#as_i8? : Int8?
Checks that the underlying value is
Int
, and returns its value as anInt8
. -
#as_i? : Int32?
Checks that the underlying value is
Int
, and returns its value as anInt32
. -
#as_nil : Nil
Checks that the underlying value is
Nil
, and returnsnil
. -
#as_s : String
Checks that the underlying value is
String
, and returns its value. -
#as_s? : String?
Checks that the underlying value is
String
, and returns its value. - #as_sym : Symbol
- #as_sym? : Symbol?
-
#as_u128 : UInt64
Checks that the underlying value is
Int
, and returns its value as anUInt64
. -
#as_u128? : UInt64?
Checks that the underlying value is
Int
, and returns its value as anUInt64
. -
#as_u16 : UInt16
Checks that the underlying value is
Int
, and returns its value as anUInt16
. -
#as_u16? : UInt16?
Checks that the underlying value is
Int
, and returns its value as anUInt16
. -
#as_u32 : UInt32
Checks that the underlying value is
Int
, and returns its value as anUInt32
. -
#as_u32? : UInt32?
Checks that the underlying value is
Int
, and returns its value as anUInt32
. -
#as_u64 : UInt64
Checks that the underlying value is
Int
, and returns its value as anUInt64
. -
#as_u64? : UInt64?
Checks that the underlying value is
Int
, and returns its value as anUInt64
. -
#as_u8 : UInt8
Checks that the underlying value is
Int
, and returns its value as anUInt8
. -
#as_u8? : UInt8?
Checks that the underlying value is
Int
, and returns its value as anUInt8
. -
#hash(hasher)
See
Object#hash(hasher)
-
#raw : Type
Returns the raw underlying value.
-
#size : Int
Assumes the underlying value is an
Array
orHash
and returns its size.
Instance methods inherited from struct Value
==(other : Quartz::Any)
==
Instance methods inherited from class Object
===(other : Quartz::Any)
===
Constructor Detail
Creates a Any
value that wraps a new Array
Creates a Any
value that wraps a new Hash
Instance Method Detail
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
.
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
.
Assumes the underlying value is a Hash
and returns the element with the
given key.
Raises if the underlying value is not a Hash
.
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
.
Assumes the underlying value is a Hash
and sets the given value at the
given key.
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
.
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
.
Assumes the underlying value is a Hash
and sets the given value at the
given key.
Assumes the underlying value is a Hash
and sets the given value at the
given key.
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
.
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
.
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
.
Checks that the underlying value is Array
, and returns its value. Raises otherwise.
Checks that the underlying value is Array
, and returns its value. Returns nil otherwise.
Checks that the underlying value is Bool
, and returns its value. Raises otherwise.
Checks that the underlying value is Bool
, and returns its value. Returns nil otherwise.
Checks that the underlying value is Char
, and returns its value. Raises otherwise.
Checks that the underlying value is Char
, and returns its value. Returns nil otherwise.
Checks that the underlying value is Float
, and returns its value as an Float64
.
Raises otherwise.
Checks that the underlying value is Float
, and returns its value as an Float32
. Raises otherwise.
Checks that the underlying value is Float
, and returns its value as an Float32
. Returns nil otherwise.
Checks that the underlying value is Float
, and returns its value as an Float64
. Raises otherwise.
Checks that the underlying value is Float
, and returns its value as an Float64
. Returns nil otherwise.
Checks that the underlying value is Float
, and returns its value as an Float64
.
Returns nil
otherwise.
Checks that the underlying value is Hash
, and returns its value. Raises otherwise.
Checks that the underlying value is Hash
, and returns its value. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an Int32
.
Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an Int128
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an Int128
. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an Int16
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an Int16
. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an Int32
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an Int32
. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an Int64
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an Int64
. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an Int8
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an Int8
. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an Int32
.
Returns nil
otherwise.
Checks that the underlying value is String
, and returns its value. Raises otherwise.
Checks that the underlying value is String
, and returns its value. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt64
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt64
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt16
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt16
. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt32
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt32
. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt64
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt64
. Returns nil otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt8
. Raises otherwise.
Checks that the underlying value is Int
, and returns its value as an UInt8
. Returns nil otherwise.
Assumes the underlying value is an Array
or Hash
and returns
its size.
Raises if the underlying value is not an Array
or Hash
.