Class: ToonFormat::Decoder

Inherits:
Object
  • Object
show all
Defined in:
lib/toon_format/decoder.rb

Overview

Decodes TOON format strings to Ruby objects

Constant Summary collapse

MAX_INPUT_SIZE =

10 MB

10 * 1024 * 1024

Class Method Summary collapse

Class Method Details

.decode(toon_string, strict: true) ⇒ Object

Decode TOON format string to Ruby object

Parameters:

  • toon_string (String)

    TOON formatted string

  • strict (Boolean) (defaults to: true)

    Enable strict validation

Returns:

  • (Object)

    Decoded Ruby object



13
14
15
16
17
18
19
20
21
22
# File 'lib/toon_format/decoder.rb', line 13

def self.decode(toon_string, strict: true)
  validate_input(toon_string)

  parser = Parser.new(toon_string, strict: strict)
  data = parser.parse

  Validator.validate!(toon_string, data) if strict

  data
end