Class: SexpPath::Matcher::All

Inherits:
Base
  • Object
show all
Defined in:
lib/sexp_path/matcher/all.rb

Overview

See SexpQueryBuilder.all

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#&, #-@, #>>, #|

Methods included from Traverse

#capture_as, #replace_sexp, #search, #search_each

Constructor Details

#initialize(*options) ⇒ All

Create an All matcher which will match all of the options.



6
7
8
# File 'lib/sexp_path/matcher/all.rb', line 6

def initialize(*options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/sexp_path/matcher/all.rb', line 3

def options
  @options
end

Instance Method Details

#inspectObject



17
18
19
# File 'lib/sexp_path/matcher/all.rb', line 17

def inspect
  options.map{|o| o.inspect}.join(' & ')
end

#satisfy?(o, data = {}) ⇒ Boolean

Satisfied when all sub expressions match o

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/sexp_path/matcher/all.rb', line 11

def satisfy?(o, data={})
  return nil unless options.all?{|exp| exp.is_a?(Sexp) ? exp.satisfy?(o, data) : exp == o}

  capture_match o, data
end