Class: Blaml::TreeBuilder

Inherits:
Psych::TreeBuilder
  • Object
show all
Defined in:
lib/blaml/tree_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(meta_binding) ⇒ TreeBuilder

Returns a new instance of TreeBuilder.



5
6
7
8
# File 'lib/blaml/tree_builder.rb', line 5

def initialize meta_binding
  @meta_binding = meta_binding
  super()
end

Instance Method Details

#add_meta(obj) ⇒ Object

Sets the @meta instance variable to the metadata matched for the string object. Returns the passed instance.



16
17
18
19
# File 'lib/blaml/tree_builder.rb', line 16

def add_meta obj
  obj.meta = @meta_binding. obj.value
  obj
end

#scalar(value, anchor, tag, plain, quoted, style) ⇒ Object

Calls parent and applies metadata to return value.



25
26
27
28
# File 'lib/blaml/tree_builder.rb', line 25

def scalar value, anchor, tag, plain, quoted, style
  super
  add_meta @last.children.last
end