Method: HTree::Location#subst
- Defined in:
- lib/htree/loc.rb
#subst(pairs) ⇒ Object
subst substitutes several subtrees at once.
t = HTree('<r><x/><y/><z/></r>')
l = t.make_loc
l2 = l.subst({
l.root.get_subnode('k') => 'v',
l.root.get_subnode(-1) => HTree('<a/>'),
l.find_element('y') => nil,
l.find_element('z').get_subnode(0) => HTree('<b/>'),
})
pp l2, l2.to_node
# =>
#<HTree::Doc::Loc: doc()>
#<HTree::Doc
{elem <r k="v"> {emptyelem <a>} {emptyelem <x>} {elem <z> {emptyelem <b>}}}>
239 240 241 |
# File 'lib/htree/loc.rb', line 239 def subst(pairs) subst_itself(@node.subst(pairs)) end |