class
TOML::Document
- TOML::Document
- Reference
- Object
Overview
Convenience method on Document itself.
Defined in:
toml.crtoml/edit.cr
toml/lookup.cr
toml/node.cr
Constructors
Instance Method Summary
- #bool(path : String) : Bool
- #bool?(path : String) : Bool | Nil
- #datetime(path : String) : Time
- #datetime?(path : String) : Time | Nil
-
#delete(key : String) : Bool
Removes the top-level KeyValueLine with the given bare key, if any.
- #float(path : String) : Float64
- #float?(path : String) : Float64 | Nil
- #get(path : String) : Type
-
#get?(path : String) : Type | Nil
Returns the decoded value at the given dotted path, or
nilif the path does not exist or any intermediate segment is not a table. - #get?(path : Array(String)) : Type | Nil
- #has_key?(path : String) : Bool
- #int(path : String) : Int64
- #int?(path : String) : Int64 | Nil
- #nodes : Array(Node)
-
#set(key : String, value : String) : Nil
Sets a top-level key to
value. - #set(key : String, value : Int) : Nil
- #set(key : String, value : Float) : Nil
- #set(key : String, value : Bool) : Nil
-
#set_with_comment(key : String, value : String, comment : String) : Nil
Same as
#setbut also sets a trailing inline comment on the line. - #set_with_comment(key : String, value : Int, comment : String) : Nil
- #string(path : String) : String
- #string?(path : String) : String | Nil
- #time_of_day(path : String) : Time::Span
- #time_of_day?(path : String) : Time::Span | Nil
-
#to_h : Hash(String, TOML::Type)
See
TOML.parse_to_hash. - #to_toml(io : IO) : Nil
-
#to_toml : String
Re-serialise the document.
- #trailing_raw : String
- #trailing_raw=(trailing_raw : String)
Constructor Detail
Instance Method Detail
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.
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.
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.
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.
Re-serialise the document. Byte-identical to the source for any unmodified document.