Module: Metamorpher::Rewriter::Replacement

Included in:
Terms::Term
Defined in:
lib/metamorpher/rewriter/replacement.rb

Instance Method Summary collapse

Instance Method Details

#replace(path, replacement) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/metamorpher/rewriter/replacement.rb', line 4

def replace(path, replacement)
  if path.empty?
    replacement.dup
  else
    Terms::Literal.new(
      name: name,
      children: children.map_at(path.first) { |e| e.replace(path.drop(1), replacement) }
    )
  end
end