Class: SexpPath::Matcher::Child
- Defined in:
- lib/sexp_path/matcher/child.rb
Overview
See SexpQueryBuilder.child
Instance Attribute Summary collapse
-
#child ⇒ Object
readonly
Returns the value of attribute child.
Instance Method Summary collapse
-
#initialize(child) ⇒ Child
constructor
Create a Child matcher which will match anything having a descendant matching
child
. - #inspect ⇒ Object
-
#satisfy?(o, data = {}) ⇒ Boolean
Satisfied if matches
child
oro
has a descendant matchingchild
.
Methods inherited from Base
Methods included from Traverse
#capture_as, #replace_sexp, #search, #search_each
Constructor Details
#initialize(child) ⇒ Child
Create a Child matcher which will match anything having a descendant matching child
.
6 7 8 |
# File 'lib/sexp_path/matcher/child.rb', line 6 def initialize(child) @child = child end |
Instance Attribute Details
#child ⇒ Object (readonly)
Returns the value of attribute child.
3 4 5 |
# File 'lib/sexp_path/matcher/child.rb', line 3 def child @child end |
Instance Method Details
#inspect ⇒ Object
21 22 23 |
# File 'lib/sexp_path/matcher/child.rb', line 21 def inspect "child(#{child.inspect})" end |
#satisfy?(o, data = {}) ⇒ Boolean
Satisfied if matches child
or o
has a descendant matching child
.
11 12 13 14 15 16 17 18 19 |
# File 'lib/sexp_path/matcher/child.rb', line 11 def satisfy?(o, data={}) if child.satisfy?(o,data) capture_match o, data elsif o.is_a? Sexp o.search_each(child,data) do return capture_match(o, data) end end end |