Class: Philiprehberger::TomlKit::CommentPreservingSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/philiprehberger/toml_kit/comment_document.rb

Overview

Serializer that outputs comments from a CommentDocument.

Instance Method Summary collapse

Instance Method Details

#serialize(doc) ⇒ String

Returns TOML with comments.

Parameters:

Returns:

  • (String)

    TOML with comments



302
303
304
305
306
307
308
309
# File 'lib/philiprehberger/toml_kit/comment_document.rb', line 302

def serialize(doc)
  # Header comments
  lines = doc.header_comments.map { |c| c }
  lines << '' unless doc.header_comments.empty?

  serialize_table(doc.data, [], lines, doc)
  lines.join("\n") << "\n"
end