Class: Jac::Parser::VisitorToRuby

Inherits:
Psych::Visitors::ToRuby
  • Object
show all
Defined in:
lib/jac/parser.rb

Overview

Cutstom Yaml AST visitor While standard Psych visitor converts sets to ‘{ value => nil }` mappings we need explicitly convert those mappings to ruby [Set]

See Also:

  • Psych::Visitors::ToRuby

Instance Method Summary collapse

Instance Method Details

#visit_Psych_Nodes_Mapping(o) ⇒ Object

Uses standard Psych visitor to convert mapping to ruby object except ‘!set` case. Here we convert mapping to [Set].

Parameters:

  • o (Psych::Nodes::Mapping)

    YAML AST node

Returns:

  • (Object)

    parsed ruby object



18
19
20
21
22
23
24
25
# File 'lib/jac/parser.rb', line 18

def visit_Psych_Nodes_Mapping(o)
  case o.tag
  when '!set', 'tag:yaml.org,2002:set'
    visit_set(o)
  else # fallback to default implementation
    super(o)
  end
end