class

TOML::Document

Inherits Reference < Object

Convenience method on Document itself.

Constructors

new(nodes : Array(Node) = [] of Node, trailing_raw : String = "")
Source

Instance methods

bool(path : String) : Bool
Source
bool?(path : String) : Bool | Nil
Source
datetime(path : String) : Time
Source
datetime?(path : String) : Time | Nil
Source
delete(key : String) : Bool

Removes the top-level KeyValueLine with the given bare key, if any. Returns true if a line was deleted, false if no such top-level key existed.

Source
float(path : String) : Float64
Source
float?(path : String) : Float64 | Nil
Source
get(path : String) : Type
Source
get?(path : String) : Type | Nil

Returns the decoded value at the given dotted path, or nil if the path does not exist or any intermediate segment is not a table.

The path uses . as a separator. Quoted segments are not supported here — if you need a key that contains a dot, use Document#get(path : Array(String)) with an explicit array of segments.

Source
get?(path : Array(String)) : Type | Nil
Source
has_key?(path : String) : Bool
Source
int(path : String) : Int64
Source
int?(path : String) : Int64 | Nil
Source
nodes
Source
set(key : String, value : String) : Nil

Sets a top-level key to value. If a top-level KeyValueLine already exists for that key, only its value (and any trailing comment if comment is given) is replaced — surrounding whitespace and comments are preserved. Otherwise a new line is inserted at the end of the top-level section (before the first table header).

comment is the trailing comment text without the leading #. Pass an empty string to clear an existing trailing comment, nil to leave it untouched on update.

The current implementation operates on a single bare key. For dotted paths or values inside [section] blocks, see issue tracker — those are planned but not in v0.1.

Source
set(key : String, value : Int) : Nil
Source
set(key : String, value : Float) : Nil
Source
set(key : String, value : Bool) : Nil
Source
set_with_comment(key : String, value : String, comment : String) : Nil

Same as #set but also sets a trailing inline comment on the line. The comment argument should not include the leading #; it is added automatically with a single space prefix.

Source
set_with_comment(key : String, value : Int, comment : String) : Nil
Source
string(path : String) : String
Source
string?(path : String) : String | Nil
Source
time_of_day(path : String) : Time::Span
Source
time_of_day?(path : String) : Time::Span | Nil
Source
to_h

See TOML.parse_to_hash.

Source
to_toml(io : IO) : Nil
Source
to_toml

Re-serialise the document. Byte-identical to the source for any unmodified document.

Source
trailing_raw
Source
trailing_raw=(trailing_raw : String)
Source