W3cubDocs

/Crystal

struct Log::Metadata::Value

Defined in:

log/metadata.cr:7
log/metadata.cr:194

Constructors

Instance Method Summary

Constructor Detail

def self.new(raw : Type)Source

Creates a Log::Metadata::Value that wraps the given Type.

def self.new(hash : NamedTuple | Hash)Source

Creates Log::Metadata from the given values. All keys are converted to String

Instance Method Detail

def ==(other : self)Source

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

def ==(other)Source

Returns true if the raw object is equal to other.

def [](index_or_key) : selfSource

Assumes the underlying value is an Array or Hash and returns the element at the given index_or_key.

Raises if the underlying value is not an Array nor a Hash.

def []?(index_or_key) : self?Source

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.

Raises if the underlying value is not an Array nor a Hash.

def as_a : Array(self)

Checks that the underlying value is Array(self), and returns its value. Raises otherwise.

def as_a? : Array(self)?

Checks that the underlying value is Array(self), and returns its value. Returns nil otherwise.

def as_bool : Bool

Checks that the underlying value is Bool, and returns its value. Raises otherwise.

def as_bool? : Bool?

Checks that the underlying value is Bool, and returns its value. Returns nil otherwise.

def as_f : Float32

Checks that the underlying value is Float32, and returns its value. Raises otherwise.

def as_f64 : Float64

Checks that the underlying value is Float64, and returns its value. Raises otherwise.

def as_f64? : Float64?

Checks that the underlying value is Float64, and returns its value. Returns nil otherwise.

def as_f? : Float32?

Checks that the underlying value is Float32, and returns its value. Returns nil otherwise.

def as_h : Hash(String, self)

Checks that the underlying value is Hash(String, self), and returns its value. Raises otherwise.

def as_h? : Hash(String, self)?

Checks that the underlying value is Hash(String, self), and returns its value. Returns nil otherwise.

def as_i : Int32

Checks that the underlying value is Int32, and returns its value. Raises otherwise.

def as_i64 : Int64

Checks that the underlying value is Int64, and returns its value. Raises otherwise.

def as_i64? : Int64?

Checks that the underlying value is Int64, and returns its value. Returns nil otherwise.

def as_i? : Int32?

Checks that the underlying value is Int32, and returns its value. Returns nil otherwise.

def as_nil : Nil

Checks that the underlying value is Nil, and returns its value. Raises otherwise.

def as_s : String

Checks that the underlying value is String, and returns its value. Raises otherwise.

def as_s? : String?

Checks that the underlying value is String, and returns its value. Returns nil otherwise.

def as_time : Time

Checks that the underlying value is Time, and returns its value. Raises otherwise.

def as_time? : Time?

Checks that the underlying value is Time, and returns its value. Returns nil otherwise.

def cloneSource

Returns a new Log::Metadata::Value instance with the #raw value #cloneed.

def dig(index_or_key, *subkeys)Source

Traverses the depth of a structure and returns the value, otherwise raises.

def dig?(index_or_key, *subkeys)Source

Traverses the depth of a structure and returns the value. Returns nil if not found.

def dupSource

Returns a new Log::Metadata::Value instance with the #raw value #duped.

def hash(hasher)

def raw : Type

Returns the raw underlying value, a Type.

def size : IntSource

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

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

© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.35.1/Log/Metadata/Value.html