class Sexp::Any

Matches when any of the sub-expressions match.

This is also available via Matcher#|.

examples:

s(:a) / s{ any(s(:a), s(:b)) } #=> [s(:a)]
s(:a) / s{     s(:a) | s(:b) } #=> [s(:a)] # same thing via |
s(:a) / s{ any(s(:b), s(:c)) } #=> []

Attributes

options[R]

The collection of sub-matchers to match against.

Public Class Methods

new(*options) click to toggle source

Create an Any matcher which will match any of the options.

# File lib/sexp_matcher.rb, line 607
def initialize *options
  @options = options
end

Public Instance Methods

satisfy?(o) click to toggle source

Satisfied when any sub expressions match o

# File lib/sexp_matcher.rb, line 614
def satisfy? o
  options.any? { |exp|
    Sexp === exp && exp.satisfy?(o) || exp == o
  }
end