class SexpPath::Matcher::Include

See SexpQueryBuilder.include

Attributes

value[R]

Public Class Methods

new(value) click to toggle source

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

# File lib/sexp_path/matcher/include.rb, line 6
def initialize(value)
  @value = value
end

Public Instance Methods

inspect() click to toggle source
# File lib/sexp_path/matcher/include.rb, line 19
def inspect
  "include(#{value.inspect})"
end
satisfy?(o, data={}) click to toggle source

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

# File lib/sexp_path/matcher/include.rb, line 11
def satisfy?(o, data={})
  if o.is_a? Sexp
    return nil unless o.any?{|c| value.is_a?(Sexp) ? value.satisfy?(c, data) : value == c}
  end

  capture_match o, data
end