class
RemiLib::RSConf::Writer
- RemiLib::RSConf::Writer
- Reference
- Object
Overview
The Writer class is used to generate properly-formatted RSConf data from
RSValues. There is also the RemiLib::RSConf::Builder class, which is
much more flexible.
require "libremiliacr"
root = RemiLib::RSConf::RSObject.new
root["test"] = 69
root["test2"] = "Hello, world!"
io = IO::Memory.new
writer = RemiLib::RSConf::Writer.new(io)
writer.write(root)
puts io.to_s
Defined in:
remilib/rsconf/writer.crConstructors
-
.new(stream : IO)
Creates a new
Writerinstance that will write data to stream.
Class Method Summary
-
.write(dest : IO, data : RSTopLevel) : Nil
Writes RSConf data to the given
IO. -
.write(data : RSTopLevel) : String
Writes RSConf data to a new string and returns it.
Instance Method Summary
-
#alwaysQuoteKeys=(alwaysQuoteKeys : Bool)
When true, then key names are always quoted, even when they don't need to be.
-
#alwaysQuoteKeys? : Bool
When true, then key names are always quoted, even when they don't need to be.
-
#alwaysUseScientificNotation=(alwaysUseScientificNotation : Bool)
When true, then float values are always written using scientific notation.
-
#alwaysUseScientificNotation? : Bool
When true, then float values are always written using scientific notation.
-
#commaAfterValues=(commaAfterValues : Bool)
When true, then a comma is always inserted after values, otherwise commas are omitted.
-
#commaAfterValues? : Bool
When true, then a comma is always inserted after values, otherwise commas are omitted.
-
#explicitRootObject=(explicitRootObject : Bool)
When true, and the toplevel value is an
RSObject, then braces will be inserted around it (similar to JSON). -
#explicitRootObject? : Bool
When true, and the toplevel value is an
RSObject, then braces will be inserted around it (similar to JSON). -
#extraNewlineBetweenToplevelKeys=(extraNewlineBetweenToplevelKeys : Bool)
When true, then an extra newline is added after every topevel key/value pair (i.e., an extra blank line between each pair).
-
#extraNewlineBetweenToplevelKeys? : Bool
When true, then an extra newline is added after every topevel key/value pair (i.e., an extra blank line between each pair).
-
#indentSize : UInt32
The size of the indent (ASCII spaces).
-
#indentSize=(indentSize : UInt32)
The size of the indent (ASCII spaces).
-
#stream : IO
Returns the underlying
IO. -
#stream=(value : IO) : Nil
Changes the destination stream.
-
#write(data : RSObject) : Nil
Writes the toplevel
RSObjectvalue. -
#write(data : RSArray) : Nil
Writes the toplevel
RSArrayvalue.
Instance methods inherited from class Object
toRsconf(io : IO, *, indentSize : Int = 2, alwaysQuoteKeys : Bool = false, explicitRootObject : Bool = false, commaAfterValues : Bool = false, extraNewlineBetweenToplevelKeys : Bool = false) : NiltoRsconf(*, indentSize : Int = 2, alwaysQuoteKeys : Bool = false, explicitRootObject : Bool = false, commaAfterValues : Bool = false, extraNewlineBetweenToplevelKeys : Bool = false) : String toRsconf
Class methods inherited from class Object
fromRsconf(toplevel : RemiLib::RSConf::RSValue)fromRsconf(data : String | IO | Path) fromRsconf
Constructor Detail
Creates a new Writer instance that will write data to stream.
Class Method Detail
Writes RSConf data to the given IO.
Writes RSConf data to a new string and returns it.
Instance Method Detail
When true, then key names are always quoted, even when they don't need to be. Otherwise they are only quoted when necessary.
When true, then key names are always quoted, even when they don't need to be. Otherwise they are only quoted when necessary.
When true, then float values are always written using scientific notation.
When true, then float values are always written using scientific notation.
When true, then a comma is always inserted after values, otherwise commas are omitted.
When true, then a comma is always inserted after values, otherwise commas are omitted.
When true, and the toplevel value is an RSObject, then braces will be
inserted around it (similar to JSON). Otherwise these are omitted, as
permitted by the specs.
When true, and the toplevel value is an RSObject, then braces will be
inserted around it (similar to JSON). Otherwise these are omitted, as
permitted by the specs.
When true, then an extra newline is added after every topevel key/value pair (i.e., an extra blank line between each pair). Otherwise only a single newline is emitted after each pair.
When true, then an extra newline is added after every topevel key/value pair (i.e., an extra blank line between each pair). Otherwise only a single newline is emitted after each pair.
Changes the destination stream. Calling this effectively "resets" the
Writer instance, allowing you to call #write again to generate new
RSConf data. The old stream is NOT closed.