Sha256: 7af7a61b3e3e2d4e919288453e1ecb922cb98394120465f4c0fa2b1d36dd4a0f

Contents?: true

Size: 503 Bytes

Versions: 5

Compression:

Stored size: 503 Bytes

Contents

# See SexpQueryBuilder.any
class SexpPath::Matcher::Any < SexpPath::Matcher::Base
  attr_reader :options
  
  # Create an Any matcher which will match any of the +options+.
  def initialize(*options)
    @options = options
  end

  # Satisfied when any sub expressions match +o+
  def satisfy?(o, data={})
    return nil unless options.any?{|exp| exp.is_a?(Sexp) ? exp.satisfy?(o, data) : exp == o}
  
    capture_match o, data
  end
  
  def inspect
    options.map{|o| o.inspect}.join(' | ')
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
adamsanderson-sexp_path-0.4.0 lib/sexp_path/matcher/any.rb
sexp_path-0.5.2 lib/sexp_path/matcher/any.rb
sexp_path-0.5.1 lib/sexp_path/matcher/any.rb
sexp_path-0.5.0 lib/sexp_path/matcher/any.rb
sexp_path-0.4.0 lib/sexp_path/matcher/any.rb