class Bplist::Any
- Bplist::Any
- Reference
- Object
Defined in:
bplist/any.crConstructors
-
.new(raw : Type)
Creates a
Bplist::Any
that wraps the given value.
Class Method Summary
-
.convert(value : _) : Bplist::Any
Method to convert a value to the
Bplist::Any
type
Instance Method Summary
-
#==(other : Bplist::Any)
Returns
true
if bothself
and other's raw object are equal. -
#==(other)
Returns
true
if the raw object is equal to other. -
#[](index : Int) : Bplist::Any
Assumes the underlying value is an
Array
and returns the element at the given index. -
#[](key : String) : Bplist::Any
Assumes the underlying value is a
Hash
and returns the element with the given key. -
#[]?(index : Int) : Bplist::Any | Nil
Assumes the underlying value is an
Array
and returns the element at the given index, ornil
if out of bounds. -
#[]?(key : String) : Bplist::Any | Nil
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(Bplist::Any)
Checks that the underlying value is
Array
, and returns its value. -
#as_a? : Array(Bplist::Any) | Nil
Checks that the underlying value is
Array
, and returns its value. -
#as_f : Float64
Checks that the underlying value is
Float
(orInt
), and returns its value as anFloat64
. -
#as_f32 : Float32
Checks that the underlying value is
Float
(orInt
), and returns its value as anFloat32
. -
#as_f32? : Float32 | Nil
Checks that the underlying value is
Float
(orInt
), and returns its value as anFloat32
. -
#as_f? : Float64 | Nil
Checks that the underlying value is
Float
(orInt
), and returns its value as anFloat64
. -
#as_h : Hash(String, Bplist::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_i64 : Int64
Checks that the underlying value is
Int
, and returns its value as anInt64
. -
#as_i64? : Int64 | Nil
Checks that the underlying value is
Int
, and returns its value as anInt64
. -
#as_i? : Int32 | Nil
Checks that the underlying value is
Int
, and returns its value as anInt32
. -
#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. -
#dig(index_or_key : String | Int, *subkeys) : Bplist::Any
Traverses the depth of a structure and returns the value, otherwise raises.
-
#dig?(index_or_key : String | Int, *subkeys) : Bplist::Any | Nil
Traverses the depth of a structure and returns the value.
-
#hash(hasher)
See
Object#hash(hasher)
-
#inspect(io : IO) : Nil
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
- #pretty_print(pp)
-
#raw : Type
Returns the raw underlying value.
-
#to_s(io : IO) : Nil
Appends a short String representation of this object which includes its class name and its object address.
Constructor Detail
Class Method Detail
Instance Method Detail
Assumes the underlying value is an Array
and returns the element
at the given index.
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 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
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 Float
(or Int
), and returns its value as an Float64
.
Raises otherwise.
Checks that the underlying value is Float
(or Int
), and returns its value as an Float32
.
Raises otherwise.
Checks that the underlying value is Float
(or Int
), and returns its value as an Float32
.
Returns nil
otherwise.
Checks that the underlying value is Float
(or Int
), 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 Int
, and returns its value as an Int32
.
Raises 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 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.
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 a String representation of this object which includes its class name, its object address and the values of all instance variables.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>