Class: Blaml::ToRuby

Inherits:
Psych::Visitors::ToRuby
  • Object
show all
Defined in:
lib/blaml/to_ruby.rb

Overview

Subclass Psych’s to_ruby to build node values with metadata.

Instance Method Summary collapse

Instance Method Details

#visit_Psych_Nodes_Mapping(o) ⇒ Object

Wraps ruby Arrays with MetaHash. See Psych::Visitors::ToRuby



34
35
36
37
38
39
# File 'lib/blaml/to_ruby.rb', line 34

def visit_Psych_Nodes_Mapping o
  mapp = super
  return mapp unless Hash === mapp

  MetaHash.new mapp
end

#visit_Psych_Nodes_Scalar(o) ⇒ Object

Wraps ruby object with MetaNode. See Psych::Visitors::ToRuby



12
13
14
# File 'lib/blaml/to_ruby.rb', line 12

def visit_Psych_Nodes_Scalar o
  MetaNode.new super, o.meta
end

#visit_Psych_Nodes_Sequence(o) ⇒ Object

Wraps ruby Arrays with MetaArray. See Psych::Visitors::ToRuby



21
22
23
24
25
26
# File 'lib/blaml/to_ruby.rb', line 21

def visit_Psych_Nodes_Sequence o
  seq  = super
  return seq unless Array === seq

  MetaArray.new seq
end