class KYAML::Builder

Overview

Imperative builder for KYAML output.

Constructs a KYAML::Any tree from #mapping / #sequence / #scalar / #field calls, then renders it through the Emitter so output is equivalent to KYAML.emit. The tree is a per-collection buffer to allow cuddling to see every child of a collection before choosing the layout.

Defined in:

kyaml/builder.cr

Constructors

Instance Method Summary

Instance methods inherited from class Reference

==(other : KYAML::Any) ==

Instance methods inherited from class Object

to_kyaml(io : IO) : Nil
to_kyaml(builder : KYAML::Builder) : Nil
to_kyaml : String
to_kyaml

Constructor Detail

def self.new(io : IO) #

[View source]

Instance Method Detail

def commit : Nil #

Renders the built tree to the IO. Called once after the build block. :nodoc:


[View source]
def document(&) : Nil #

Wraps the built root value as a doc (--- header + trailing newline).


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

Adds a key / scalar-value pair to the current mapping.


[View source]
def field(key : String, &) : Nil #

Adds a key whose value is a nested collection built by the block.


[View source]
def mapping(&) : Nil #

Builds a mapping in the current context.


[View source]
def scalar(value) : Nil #

Adds a scalar value to the current sequence.


[View source]
def sequence(&) : Nil #

Builds a sequence in the current context.


[View source]