struct Config::Any

Included Modules

Defined in:

config/any.cr

Constructors

Instance Method Summary

Instance methods inherited from class Object

===(other : Config::Any) ===

Constructor Detail

def self.new(raw : Config::Type) #

Creates a Config::Any that wraps the given Config::Type.


[View source]

Instance Method Detail

def ==(other) #

Returns true if the raw object is equal to other.


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

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


[View source]
def [](index : Int::Primitive) : 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.


[View source]
def [](key : String) : 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 []?(index : Int::Primitive) : Any? #

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 : String) : 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(*path : KeyTypes) : Array(Any) #

Assumes the underlying value is indexable and returns the specified element at the given key path as an Array(Any).

Raises if it is not an Array or not found.


[View source]
def as_a(*path : KeyTypes, each_as : U.class, &block : U -> Nil) : Nil forall U #

Assumes the underlying value is indexable and yields each element at the given key path as type U.

Raises if it is not an Array, not found, or an entry is not able to be cast to type U.


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

Returns the underlying value as an Array(Any) if it can.

Raises otherwise.


[View source]
def as_a(*path : KeyTypes, each_as : U.class) : Array(U) forall U #

Assumes the underlying value is indexable and returns the specified element at the given key path as an Array of type U.

Raises if it is not an Array, not found, or an entry is not able to be cast to type U.


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

Returns the underlying value as an Array(Any) if it can.

Returns nil otherwise.


[View source]
def as_a?(*path : KeyTypes) : Array(Any)? #

Assumes the underlying value is indexable and returns the specified element at the given key path as an Array(Any).

Returns nil if it is not an Array or not found.


[View source]
def as_a?(*path : KeyTypes, each_as : U.class? = nil, &block : U -> Nil) : Bool forall U #

Assumes the underlying value is indexable and yields each element at the given key path as type U.

Returns a Bool indicating if the Array was found.

Note: If an entry is not able to be cast to type U it is skipped.


[View source]
def as_a?(*path : KeyTypes, each_as : U.class, skip : Bool = true) : Array(U)? forall U #

Assumes the underlying value is indexable and returns the specified element at the given key path as an Array of type U.

Returns nil if it is not an Array or not found.

Note: If an entry is not able to be cast to type U and skip is not false (the default) it is skipped.


[View source]
def as_bool(*path : KeyTypes) : Bool #

Assumes the underlying value is indexable and returns the element with the given key as a Bool.

Raises otherwise.


[View source]
def as_bool : Bool #

Returns the underlying value as an Bool if it can.

Raises otherwise.


[View source]
def as_bool?(*path : KeyTypes) : Bool? #

Assumes the underlying value is indexable and returns the element with the given key as a Bool.

Returns nil otherwise.


[View source]
def as_bool? : Bool? #

Returns the underlying value as an Bool if it can.

Returns nil otherwise.


[View source]
def as_f : Float64 #

Returns the underlying value as an Float64 if it can.

Raises otherwise.


[View source]
def as_f(*path : KeyTypes) : Float64 #

Assumes the underlying value is indexable and returns the element with the given key as a Float64.

Raises otherwise.


[View source]
def as_f32(*path : KeyTypes) : Float32 #

Assumes the underlying value is indexable and returns the element with the given key as a Float32.

Raises otherwise.


[View source]
def as_f32 : Float32 #

Returns the underlying value as an Float32 if it can.

Raises otherwise.


[View source]
def as_f32?(*path : KeyTypes) : Float32? #

Assumes the underlying value is indexable and returns the element with the given key as a Float32.

Returns nil otherwise.


[View source]
def as_f32? : Float32? #

Returns the underlying value as an Float32 if it can.

Returns nil otherwise.


[View source]
def as_f? : Float64? #

Returns the underlying value as an Float64 if it can.

Returns nil otherwise.


[View source]
def as_f?(*path : KeyTypes) : Float64? #

Assumes the underlying value is indexable and returns the element with the given key as a Float64.

Returns nil otherwise.


[View source]
def as_h(*path : KeyTypes, each_as : U.class) : Hash(String, U) forall U #

Assumes the underlying value is indexable and returns the specified element at the given key path as a Hash of type U.

Raises if it is not an Hash, not found, or an entry is not able to be cast to type U.


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

Returns the underlying value as an Hash(String, Any) if it can.

Raises otherwise.


[View source]
def as_h(*path : KeyTypes) : Hash(String, Any) #

Assumes the underlying value is indexable and returns the specified element at the given key path as an Hash(String, Any).

Raises if it is not an Hash or not found.


[View source]
def as_h(*path : KeyTypes, each_as : U.class, &block : String, U -> Nil) : Nil forall U #

Assumes the underlying value is indexable and yields each element at the given key path as type U.

Raises if it is not a Hash, not found, or an entry is not able to be cast to type U.


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

Returns the underlying value as an Hash(String, Any) if it can.

Returns nil otherwise.


[View source]
def as_h?(*path : KeyTypes) : Hash(String, Any)? #

Assumes the underlying value is indexable and returns the specified element at the given key path as an Hash(String, Any).

Returns nil if it is not an Hash or not found.


[View source]
def as_h?(*path : KeyTypes, each_as : U.class? = nil, &block : String, U -> Nil) : Bool forall U #

Assumes the underlying value is indexable and yields each element at the given key path as type U.

Returns a Bool indicating if the Hash was found.

Note: If an entry is not able to be cast to type U it is skipped.


[View source]
def as_h?(*path : KeyTypes, each_as : U.class, skip : Bool = true) : Hash(String, U)? forall U #

Assumes the underlying value is indexable and returns the specified element at the given key path as a Hash of type U.

Returns nil if it is not a Hash or not found.

Note: If an entry is not able to be cast to type U and skip is not false (the default) it is skipped.


[View source]
def as_i(*path : KeyTypes) : Int32 #

Assumes the underlying value is indexable and returns the element with the given key as a Int32.

Raises otherwise.


[View source]
def as_i : Int32 #

Returns the underlying value as an Int32 if it can.

Raises otherwise.


[View source]
def as_i128 : Int128 #

Returns the underlying value as an Int128 if it can.

Raises otherwise.


[View source]
def as_i128(*path : KeyTypes) : Int128 #

Assumes the underlying value is indexable and returns the element with the given key as a Int128.

Raises otherwise.


[View source]
def as_i128?(*path : KeyTypes) : Int128? #

Assumes the underlying value is indexable and returns the element with the given key as a Int128.

Returns nil otherwise.


[View source]
def as_i128? : Int128? #

Returns the underlying value as an Int128 if it can.

Returns nil otherwise.


[View source]
def as_i64(*path : KeyTypes) : Int64 #

Assumes the underlying value is indexable and returns the element with the given key as a Int64.

Raises otherwise.


[View source]
def as_i64 : Int64 #

Returns the underlying value as an Int64 if it can.

Raises otherwise.


[View source]
def as_i64? : Int64? #

Returns the underlying value as an Int64 if it can.

Returns nil otherwise.


[View source]
def as_i64?(*path : KeyTypes) : Int64? #

Assumes the underlying value is indexable and returns the element with the given key as a Int64.

Returns nil otherwise.


[View source]
def as_i?(*path : KeyTypes) : Int32? #

Assumes the underlying value is indexable and returns the element with the given key as a Int32.

Returns nil otherwise.


[View source]
def as_i? : Int32? #

Returns the underlying value as an Int32 if it can.

Returns nil otherwise.


[View source]
def as_s(*path : KeyTypes) : String #

Assumes the underlying value is indexable and returns the element with the given key as a String.

Raises otherwise.


[View source]
def as_s : String #

Returns the underlying value as an String if it can.

Raises otherwise.


[View source]
def as_s?(*path : KeyTypes) : String? #

Assumes the underlying value is indexable and returns the element with the given key as a String.

Returns nil otherwise.


[View source]
def as_s? : String? #

Returns the underlying value as an String if it can.

Returns nil otherwise.


[View source]
def dig(*path : KeyTypes) : Any #

Extracts the nested value specified by the sequence of path keys by calling dig at each step, raising if any intermediate step fails.


[View source]
def dig?(*path : KeyTypes) : Any? #

Extracts the nested value specified by the sequence of path keys by calling dig at each step, returning nil if any intermediate step is nil.


[View source]
def each(&block : Any -> _) #

Assumes the underlying value is an Array or Hash and yields each of the elements or key/values, always as Config::Any. Raises if the underlying value is not an Array or Hash.


[View source]
def hash(hasher) #

See Object#hash(hasher)


[View source]
def is_nil?(*path : KeyTypes) : Bool #

Assumes the underlying value is indexable and returns a Bool that indicates if the element at the given paths underlying value is Nil.

Raises if nothing exists at path.


[View source]
def is_nil? : Bool #

Returns a Bool indicating if the value at the key is nil.


[View source]
def raw : Config::Type #

Returns the raw underlying value, a Config::Type.


[View source]
def size : Int #

Assumes the underlying value is an Array, Hash, or String and returns its size.

Raises if the underlying value is not an Array, Hash, or String.


[View source]
def size? : Int32? #

Assumes the underlying value is an Array, Hash, or String and returns its size.

Raises if the underlying value is not an Array, Hash, or String.


[View source]