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.rb, line 947
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.rb, line 954
def satisfy? o
  options.any? { |exp|
    Sexp === exp && exp.satisfy?(o) || exp == o
  }
end