Class: AceMQ::AMQP::TOMLCodec::Writer Private

Inherits:
Object
  • Object
show all
Defined in:
lib/acemq/amqp/codec/toml/writer.rb

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.

Turns a Hash into TOML text.

Values that belong to the table come first and the sub-tables after them, because TOML reads every key after a [header] as belonging to that header — a scalar written after a sub-table would silently move into it.

Strings are written as basic strings, with double quotes, which is what BurntSushi's encoder writes in the Go library. Jackson writes literal strings with single quotes in the Java one. Both are TOML, and both read back identically here; the choice only decides what a person sees.

Constant Summary collapse

ESCAPES =

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.

{
  "\\" => "\\\\", '"' => '\\"', "\b" => "\\b", "\t" => "\\t",
  "\n" => "\\n", "\f" => "\\f", "\r" => "\\r"
}.freeze
NEEDS_ESCAPING =

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.

Backslash, quote, and the control characters, which TOML does not allow to stand in a basic string.

/[\\"[:cntrl:]]/
UNQUOTED_KEY =

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.

/\A[A-Za-z0-9_-]+\z/

Instance Method Summary collapse

Instance Method Details

#write(table) ⇒ 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.

Parameters:

  • table (Hash)

Returns:

  • (String)


51
52
53
54
55
# File 'lib/acemq/amqp/codec/toml/writer.rb', line 51

def write(table)
  out = +""
  emit(table, [], out)
  out
end