Oyl::Any
Oyl::Any is a convenient wrapper around all possible YAML values
(Oyl::Any::Type) and can be used for traversing dynamic or unknown
YAML structures.
require "oyl"
data = Oyl.parse("---\nname: oyl\nversion: 0.1.0")
data["name"].as_s # => "oyl"
data["version"].as_s # => "0.1.0"
Constructors
Creates a Oyl::Any from a Oyl::Nodes::Node, typing scalars with
the context's dialect. A << key stays a key: Oyl.parse has the
parser apply merges.
Instance methods
Assumes the underlying value is an Array and returns the
element at the given index.
Assumes the underlying value is a Hash and returns the
value for the given key.
Checks that the underlying value is Bool, and returns its
value. Returns nil otherwise.
Checks that the underlying value is Float64, and returns
its value as Float32. Returns nil otherwise.
Checks that the underlying value is Float64, and returns its
value. Returns nil otherwise.
Checks that the underlying value is Int64, and returns its
value. Returns nil otherwise.
Checks that the underlying value is Int64, and returns its
value as Int32. Returns nil otherwise.
Checks that the underlying value is String, and returns its
value. Returns nil otherwise.
Checks that the underlying value is Time, and returns its
value. Returns nil otherwise.
Checks that the underlying value is UInt64, and returns its value.
Only integers above Int64::MAX are read as one.
Checks that the underlying value is UInt64, 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, otherwise raises.
Traverses the depth of a structure and returns the value,
or nil.
Traverses the depth of a structure and returns the value,
or nil.
See Object#hash(hasher)
Appends this struct's name and instance variables names and values to the given IO.
struct Point
def initialize(@x : Int32, @y : Int32)
end
end
p1 = Point.new 1, 2
p1.to_s # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"
Writes this value as a YAML document (see Oyl.dump).
Writes this value as a YAML document (see Oyl.dump).