Class: REXML::CSSSelector::Queries::HasQuery
- Inherits:
-
Object
- Object
- REXML::CSSSelector::Queries::HasQuery
- Defined in:
- lib/rexml/css_selector/queries/has_query.rb
Instance Method Summary collapse
- #call(node, context) ⇒ Object
-
#initialize(cont:, query:, needs_parent:) ⇒ HasQuery
constructor
A new instance of HasQuery.
Constructor Details
#initialize(cont:, query:, needs_parent:) ⇒ HasQuery
Returns a new instance of HasQuery.
7 8 9 10 11 |
# File 'lib/rexml/css_selector/queries/has_query.rb', line 7 def initialize(cont:, query:, needs_parent:) @cont = cont @query = query @needs_parent = needs_parent end |
Instance Method Details
#call(node, context) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rexml/css_selector/queries/has_query.rb', line 13 def call(node, context) matched = false context.scoped(node) do base = node base = context.adapter.get_parent_node(base) if @needs_parent context .adapter .each_recursive_node(base) do |child| next if node == child if @query.call(child, context) matched = true break end end end matched && @cont.call(node, context) end |