struct MaxMindDB::Any
Defined in:
maxminddb/any.crConstructors
-
.new(raw : Type)
Creates a
MaxMindDB::Anythat wraps the givenType.
Instance Method Summary
-
#==(other : self)
Returns
trueif bothselfand other's raw object are equal. -
#==(other)
Returns
trueif the raw object is equal to other. - #[](index_or_key) : self
- #[]?(index_or_key) : self | Nil
-
#as_a : Array(self)
Checks that the underlying value is
Array(self), and returns its value. -
#as_a? : Array(self) | Nil
Checks that the underlying value is
Array(self), and returns its value. -
#as_bool : Bool
Checks that the underlying value is
Bool, and returns its value. -
#as_bool? : Bool | Nil
Checks that the underlying value is
Bool, and returns its value. -
#as_f : Float64
Checks that the underlying value is
Float64, and returns its value. -
#as_f32 : Float32
Checks that the underlying value is
Float32, and returns its value. -
#as_f32? : Float32 | Nil
Checks that the underlying value is
Float32, and returns its value. -
#as_f? : Float64 | Nil
Checks that the underlying value is
Float64, and returns its value. -
#as_h : Hash(String, self)
Checks that the underlying value is
Hash(String, self), and returns its value. -
#as_h? : Hash(String, self) | Nil
Checks that the underlying value is
Hash(String, self), and returns its value. -
#as_i : Int32
Checks that the underlying value is
Int32, and returns its value. -
#as_i? : Int32 | Nil
Checks that the underlying value is
Int32, and returns its value. -
#as_nil : Nil
Checks that the underlying value is
Nil, and returns its value. -
#as_s : String
Checks that the underlying value is
String, and returns its value. -
#as_s? : String | Nil
Checks that the underlying value is
String, and returns its value. -
#as_u128 : UInt128
Checks that the underlying value is
UInt128, and returns its value. -
#as_u128? : UInt128 | Nil
Checks that the underlying value is
UInt128, and returns its value. -
#as_u16 : UInt16
Checks that the underlying value is
UInt16, and returns its value. -
#as_u16? : UInt16 | Nil
Checks that the underlying value is
UInt16, and returns its value. -
#as_u32 : UInt32
Checks that the underlying value is
UInt32, and returns its value. -
#as_u32? : UInt32 | Nil
Checks that the underlying value is
UInt32, and returns its value. -
#as_u64 : UInt64
Checks that the underlying value is
UInt64, and returns its value. -
#as_u64? : UInt64 | Nil
Checks that the underlying value is
UInt64, and returns its value. -
#clone
Returns a new
MaxMindDB::Anyinstance with the#rawvalue#cloneed. -
#dig(index_or_key, *subkeys) : self
Traverses the depth of a structure and returns the value, otherwise raises.
-
#dig?(index_or_key, *subkeys) : self | Nil
Traverses the depth of a structure and returns the value.
-
#dup
Returns a new
MaxMindDB::Anyinstance with the#rawvalue#duped. - #empty?
- #found?
-
#hash(hasher)
See
Object#hash(hasher) -
#inspect(io : IO) : Nil
Appends this struct's name and instance variables names and values to the given IO.
-
#raw : Type
Returns the raw underlying value, a
Type. - #size : Int
- #to_json(json : ::JSON::Builder)
-
#to_s(io : IO) : Nil
Same as
#inspect(io).
Instance methods inherited from struct Value
==(other : MaxMindDB::Any)
==
Instance methods inherited from class Object
===(other : MaxMindDB::Any)
===
Constructor Detail
Instance Method Detail
Assumes the underlying value is an Array or Hash and returns the element
at the given index_or_key, or nil if out of bounds or the key is missing.
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 Float64, and returns its value.
Raises otherwise.
Checks that the underlying value is Float32, and returns its value.
Raises otherwise.
Checks that the underlying value is Float32, and returns its value.
Returns nil otherwise.
Checks that the underlying value is Float64, and returns its value.
Returns nil otherwise.
Checks that the underlying value is Hash(String, self), and returns its value.
Returns nil otherwise.
Checks that the underlying value is Int32, and returns its value.
Raises otherwise.
Checks that the underlying value is Int32, and returns its value.
Returns nil otherwise.
Checks that the underlying value is Nil, and returns its value.
Raises 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 UInt128, and returns its value.
Raises otherwise.
Checks that the underlying value is UInt128, and returns its value.
Returns nil otherwise.
Checks that the underlying value is UInt16, and returns its value.
Raises otherwise.
Checks that the underlying value is UInt16, and returns its value.
Returns nil otherwise.
Checks that the underlying value is UInt32, and returns its value.
Raises otherwise.
Checks that the underlying value is UInt32, and returns its value.
Returns nil otherwise.
Checks that the underlying value is UInt64, and returns its value.
Raises otherwise.
Checks that the underlying value is UInt64, and returns its value.
Returns nil otherwise.
Traverses the depth of a structure and returns the value, otherwise raises.
Traverses the depth of a structure and returns the value.
Returns nil if not found.
Appends this struct's name and instance variables names and values to the given IO.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p1.to_s # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"