class Jac::Parser::VisitorToRuby
Cutstom Yaml AST visitor @see Psych::Visitors::ToRuby While standard Psych visitor converts sets to `{ value => nil }` mappings we need explicitly convert those mappings to ruby [Set]
Public Instance Methods
visit_Psych_Nodes_Mapping(o)
click to toggle source
Uses standard Psych visitor to convert mapping to ruby object except `!set` case. Here we convert mapping to [Set]. @param [Psych::Nodes::Mapping] o YAML AST node @return [Object] parsed ruby object
Calls superclass method
# 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
Private Instance Methods
visit_set(o)
click to toggle source
rubocop: enable Naming/MethodName
# File lib/jac/parser.rb, line 30 def visit_set(o) set = Set.new # Update anchor @st[o.anchor] = set if o.anchor o.children.each_slice(2) do |k, _v| set << accept(k) end set end