module Hpricot::Container::Trav
def filter(&block)
It doesn't return location object even if self is location object.
+filter+ returns an node.
inner nodes are examined.
If given block returns true, corresponding node is retained and
If given block returns false, corresponding node is dropped.
+filter+ yields each node except top node.
loc.filter {|descendant_loc| predicate } -> node
node.filter {|descendant_node| predicate } -> node
+filter+ rebuilds the tree without some components.
def filter(&block) subst = {} each_child_with_index {|descendant, i| if yield descendant if descendant.elem? subst[i] = descendant.filter(&block) else subst[i] = descendant end else subst[i] = nil end } to_node.subst_subnode(subst) end