class Sexp::Include

Matches an expression or any expression that includes the child.

examples:

s(:a, :b)   / s{ include(:b) } #=> [s(:a, :b)]
s(s(s(:a))) / s{ include(:a) } #=> [s(:a)]

Attributes

value[R]

The value that should be included in the match.

Public Class Methods

new(value) click to toggle source

Creates a Matcher which will match any Sexp that contains the value.

# File lib/sexp.rb, line 1260
def initialize value
  @value = value
end

Public Instance Methods

satisfy?(o) click to toggle source

Satisfied if a o is a Sexp and one of o's elements matches value

# File lib/sexp.rb, line 1268
def satisfy? o
  Sexp === o && o.any? { |c|
    # TODO: switch to respond_to??
    Sexp === value ? value.satisfy?(c) : value == c
  }
end