class KDL::Value

Defined in:

kdl/value.cr

Constructors

Instance Method Summary

Instance methods inherited from class Reference

==(other : KDL::Value) ==

Instance methods inherited from class Object

===(other : KDL::Value) ===

Constructor Detail

def self.new(value : Type, *, type : String | Nil = nil, format : String | Nil = nil) #

[View source]

Instance Method Detail

def ==(other : KDL::Value) #

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


[View source]
def ==(other) #

Returns true if the value object is equal to other.


[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_f : Float64 #

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


[View source]
def as_f32 : Float32 #

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


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

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


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

Checks that the underlying value is Float (or Int), and returns its value as an Float64. 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_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_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_type(type : String | Nil) #

[View source]
def hash(hasher) #

See Object#hash(hasher)


[View source]
def inspect(io : IO) : Nil #
Description copied from class Reference

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>

[View source]
def to_s(io : IO) : Nil #
Description copied from class Reference

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>

[View source]
def type : String | Nil #

[View source]
def type=(type : String | Nil) #

[View source]
def value : Type #

Returns the raw underlying value.


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

Returns the raw underlying value.


[View source]