Class: Tomlib::Dumper Private
- Inherits:
-
Object
- Object
- Tomlib::Dumper
- Defined in:
- lib/tomlib/dumper.rb,
ext/tomlib/tomlib.c
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
TOML generator
Constant Summary collapse
- INDENT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Indent characters
' '.freeze
- INF_POSITIVE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Representation of Infinity in TOML
'inf'.freeze
- INF_NEGATIVE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Representation of negative Infinity in TOML
'-inf'.freeze
- NAN =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Representation of NaN in TOML
'nan'.freeze
- ESCAPE_CHARS_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regex to match escape chars
/[\x00-\x1F\x22\x5C\x7F]/.freeze
- ESCAPE_CHARS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Escape chars mapping
{ "\b" => 'b', "\t" => 't', "\n" => 'n', "\f" => 'f', "\r" => 'r', '"' => '"', '\\' => '\\', }.freeze
Instance Method Summary collapse
-
#dump(hash) ⇒ String
private
Generate TOML string from ruby Hash.
-
#initialize(use_indent: true) ⇒ Dumper
constructor
private
A new instance of Dumper.
Constructor Details
#initialize(use_indent: true) ⇒ Dumper
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Dumper.
46 47 48 |
# File 'lib/tomlib/dumper.rb', line 46 def initialize(use_indent: true) @use_indent = use_indent end |
Instance Method Details
#dump(hash) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Generate TOML string from ruby Hash
57 58 59 60 61 62 63 |
# File 'lib/tomlib/dumper.rb', line 57 def dump(hash) result = dump_hash(hash) result[0] = '' if result[0] == "\n" result end |