struct UCL::Value

Overview

A thin wrapper around a Hash(String, Type), and the namespace for the Type union returned by the public API.

Value behaves like a string-keyed hash (#[], #[]?, #[]=, #each, #delete) and can be serialized with #to_json / #to_yaml.

NOTE this is a struct wrapping a Hash (a reference). Copying a Value shares the same underlying hash, so mutations are visible through every copy — treat it as a handle, not a value type.

Defined in:

ucl/value.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Creates an empty value backed by a fresh Hash(String, Type).


[View source]

Instance Method Detail

def [](key : String) #

Returns the value for key, raising KeyError if it is missing.


[View source]
def []=(key : String, value) #

Sets the value for key.


[View source]
def []?(key : String) #

Returns the value for key, or nil if it is missing.


[View source]
def delete(*args, **options) #

[View source]
def delete(*args, **options, &) #

[View source]
def each(*args, **options) #

[View source]
def each(*args, **options, &) #

[View source]

Returns the underlying Hash(String, Type).


[View source]
def to_h(*args, **options) #

[View source]
def to_h(*args, **options, &) #

[View source]
def to_json(*args, **options) #

[View source]
def to_json(*args, **options, &) #

[View source]
def to_ucl(emit_type : String | UCL::Emitter = UCL::Encoder::DEFAULT_EMITTER) : String #

Serializes the underlying hash to UCL/JSON/YAML/MsgPack. See UCL.dump.


[View source]
def to_yaml(*args, **options) #

[View source]
def to_yaml(*args, **options, &) #

[View source]