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.rb, line 1094
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.rb, line 1102
def satisfy? o
  if child.satisfy? o
    true
  elsif o.kind_of? Sexp
    o.search_each(child).any?
  end
end