class Sexp::Child
Matches anything that has a child matching the sub-expression
example:
s(s(s(s(s(:a))))) / s{ child(s(:a)) } #=> [s(s(s(s(s(:a))))), s(s(s(s(:a)))), s(s(s(:a))), s(s(:a)), s(:a)]
Attributes
child[R]
The child to match.
Public Class Methods
new(child)
click to toggle source
Create a Child
matcher which will match anything having a descendant matching child
.
# File lib/sexp_matcher.rb, line 754 def initialize child @child = child end
Public Instance Methods
satisfy?(o)
click to toggle source
Satisfied if matches child
or o
has a descendant matching child
.
# File lib/sexp_matcher.rb, line 762 def satisfy? o child.satisfy?(o) || (o.kind_of?(Sexp) && o.search_each(child).any?) end