class YamlPath::TreeBuilder
Public Class Methods
new(yaml_path:, replace_proc:)
click to toggle source
Calls superclass method
# File lib/yaml_path/tree_builder.rb, line 23 def initialize(yaml_path:, replace_proc:) super() @yaml_path = yaml_path @replace_proc = replace_proc @path_stack = PathStack.new end
Public Instance Methods
alias(*)
click to toggle source
Calls superclass method
# File lib/yaml_path/tree_builder.rb, line 47 def alias(*) super.tap do if YAML::Nodes::Mapping === @last if @last.children.size.odd? # noop else @path_stack.pop end end end end
scalar(value, anchor, tag, plain, quoted, style)
click to toggle source
Calls superclass method
# File lib/yaml_path/tree_builder.rb, line 31 def scalar(value, anchor, tag, plain, quoted, style) if @path_stack.match?(@yaml_path) value = @replace_proc.call(value) end super(value, anchor, tag, plain, quoted, style).tap do if YAML::Nodes::Mapping === @last if @last.children.size.odd? @path_stack.push(@last.children.last.value) else @path_stack.pop end end end end