Module: ContextSpook::TOON

Included in:
Generator::Context
Defined in:
lib/context_spook/toon.rb

Overview

The ContextSpook::TOON module provides TOON (Token-Oriented Object Notation) serialization functionality for context objects.

Instance Method Summary collapse

Instance Method Details

#to_toonString

Converts the context object to TOON format.

Returns:

  • (String)

    the TOON-encoded representation of the context



9
10
11
# File 'lib/context_spook/toon.rb', line 9

def to_toon
  ::Toon.encode(as_json)
end

#toon_exampleString

The toon_example method reads and returns the content of an example Markdown file that demonstrates the TOON (Token-Oriented Object Notation) format.

This method is used to provide a sample representation of how context data can be formatted in TOON, which is an alternative serialization format supported by the ContextSpook library.

Returns:

  • (String)

    the content of the TOON example Markdown file



30
31
32
# File 'lib/context_spook/toon.rb', line 30

def toon_example
  File.read(Pathname.new(__dir__) + 'toon/example.md')
end

#toon_sizeInteger

Calculates the size of the TOON representation.

Returns:

  • (Integer)

    the size in bytes of the TOON representation



17
18
19
# File 'lib/context_spook/toon.rb', line 17

def toon_size
  to_toon.size
end