Class: SexpPath::Matcher::Include
- Defined in:
- lib/sexp_path/matcher/include.rb
Overview
See SexpQueryBuilder.include
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value) ⇒ Include
constructor
Creates a Matcher which will match any Sexp that contains the
value
. - #inspect ⇒ Object
-
#satisfy?(o, data = {}) ⇒ Boolean
Satisfied if a
o
is a Sexp and one ofo
‘s elements matches value.
Methods inherited from Base
Methods included from Traverse
#capture_as, #replace_sexp, #search, #search_each
Constructor Details
#initialize(value) ⇒ Include
Creates a Matcher which will match any Sexp that contains the value
6 7 8 |
# File 'lib/sexp_path/matcher/include.rb', line 6 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/sexp_path/matcher/include.rb', line 3 def value @value end |
Instance Method Details
#inspect ⇒ Object
19 20 21 |
# File 'lib/sexp_path/matcher/include.rb', line 19 def inspect "include(#{value.inspect})" end |
#satisfy?(o, data = {}) ⇒ Boolean
Satisfied if a o
is a Sexp and one of o
‘s elements matches value
11 12 13 14 15 16 17 |
# 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 |