class
C0::Builder
- C0::Builder
- Reference
- Object
Overview
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
Defined in:
c0/builder.crConstructors
Class Method Summary
Instance Method Summary
-
#block(text : String) : Nil
Write a content block (RS + text) for document mode.
-
#eot : Nil
Write an EOT marker.
-
#etb(payload : String | Nil = nil) : Nil
Write an ETB commit marker (stream mode), with an optional integrity payload.
-
#field(value : String) : Nil
Write a raw field value (for use within records when building fields individually).
-
#file(name : String, &) : Nil
Write a file/database scope.
-
#file(name : String) : Nil
Write a file/database scope (no block).
-
#group(name : String, headers : Indexable(String) | Nil = nil, &) : Nil
Write a group/table scope with optional headers.
-
#group(name : String, headers : Indexable(String) | Nil = nil) : Nil
Write a group/table scope (no block).
-
#header(names : Indexable(String)) : Nil
Write a standalone SOH header (e.g.
-
#item(text : String) : Nil
Write a list item (US + text) for document mode.
-
#nested(&) : Nil
Write a nested sub-structure.
-
#record(fields : Indexable(String)) : Nil
Write a record from an array of fields.
-
#record(*fields : String) : Nil
Write a record with positional fields.
-
#ref(name : String) : Nil
Write a reference to a named group.
-
#ref(*path : String) : Nil
Write a path reference (group, record id, optional field).
-
#section(name : String, depth : Int32 = 1, &) : Nil
Write GS×N for document-mode depth.
-
#section(name : String, depth : Int32 = 1) : Nil
Write GS×N for document-mode depth (no block).
- #to_slice : Bytes
Constructor Detail
Class Method Detail
Instance Method Detail
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.
Write a raw field value (for use within records when building fields individually).
Write a group/table scope with optional headers.
Write a group/table scope (no block).
Write a standalone SOH header (e.g. for stream mode, where the header is appended and committed separately from the group).
Write GS×N for document-mode depth (no block).