A thin, typed view over a decoded UCL::Value::Type, in the spirit of
JSON::Any. Lets callers navigate and coerce values without manual casts:
cfg = UCL.load_any(File.read("app.conf"))
cfg["server"]["port"].as_i # => 8080
cfg["server"]["hosts"].as_a # => [UCL::Any, ...]
Instance methods
Returns the element for the object key, wrapped. Raises if the value is
not an object or the key is missing.
SourceReturns the element at array index, wrapped. Raises if not an array.
SourceLike #[](String) but returns nil when this is not an object or the key
is absent.
Source[]?(index :
Int) :
Any |
Nil Like #[](Int) but returns nil when this is not an array or the index is
out of range.
Sourceas_a
Returns the array elements, each wrapped in Any. Raises if not an array.
Sourceas_bool
Coerces to Bool, raising TypeCastError on a mismatch.
Sourceas_bool?
Coerces to Bool?, returning nil on a mismatch.
Sourceas_f
Coerces to Float64, raising TypeCastError on a mismatch.
Sourceas_f?
Coerces to Float64?, returning nil on a mismatch.
Sourceas_h
Returns the object entries, each value wrapped in Any. Raises if not an
object.
Sourceas_i
Coerces to Int64, raising TypeCastError on a mismatch.
Sourceas_i?
Coerces to Int64?, returning nil on a mismatch.
Sourceas_s
Coerces to String, raising TypeCastError on a mismatch.
Sourceas_s?
Coerces to String?, returning nil on a mismatch.
Sourceraw
The wrapped decoded value.
SourceSerializes the wrapped value to UCL/JSON/YAML/MsgPack. See UCL.dump.
Source