class

C0::Builder

Inherits Reference / Object

Builds C0DATA documents in compact form.

Example: buf = C0::Builder.build do |b| b.file("mydb") do b.group("users", headers: ["name", "amount", "type"]) do b.record("Alice", "1502.30", "DEPOSIT") b.record("Bob", "340.00", "WITHDRAWAL") end end end

Constructors

Class methods

build
Source

Instance methods

block(text : String) : Nil

Write a content block (RS + text) for document mode.

Source
eot

Write an EOT marker.

Source
etb(payload : String | Nil = nil) : Nil

Write an ETB commit marker (stream mode), with an optional integrity payload. The payload may not contain control bytes — it is terminated by the next control code on read.

Source
field(value : String) : Nil

Write a raw field value (for use within records when building fields individually).

Source
file(name : String, &) : Nil

Write a file/database scope.

Source
file(name : String) : Nil

Write a file/database scope (no block).

Source
group(name : String, headers : Indexable(String) | Nil = nil, &) : Nil

Write a group/table scope with optional headers.

Source
group(name : String, headers : Indexable(String) | Nil = nil) : Nil

Write a group/table scope (no block).

Source
header(names : Indexable(String)) : Nil

Write a standalone SOH header (e.g. for stream mode, where the header is appended and committed separately from the group).

Source
item(text : String) : Nil

Write a list item (US + text) for document mode.

Source
nested

Write a nested sub-structure.

Source
record(fields : Indexable(String)) : Nil

Write a record from an array of fields.

Source
record(*fields : String) : Nil

Write a record with positional fields.

Source
ref(name : String) : Nil

Write a reference to a named group.

Source
ref(*path : String) : Nil

Write a path reference (group, record id, optional field).

Source
section(name : String, depth : Int32 = 1, &) : Nil

Write GS×N for document-mode depth.

Source
section(name : String, depth : Int32 = 1) : Nil

Write GS×N for document-mode depth (no block).

Source
to_slice
Source