Class: REXML::CSSSelector::Queries::DescendantQuery
- Inherits:
-
Object
- Object
- REXML::CSSSelector::Queries::DescendantQuery
- Defined in:
- lib/rexml/css_selector/queries/descendant_query.rb
Instance Method Summary collapse
- #call(node, context) ⇒ Object
-
#initialize(cont:) ⇒ DescendantQuery
constructor
A new instance of DescendantQuery.
Constructor Details
#initialize(cont:) ⇒ DescendantQuery
Returns a new instance of DescendantQuery.
15 16 17 |
# File 'lib/rexml/css_selector/queries/descendant_query.rb', line 15 def initialize(cont:) @cont = cont end |
Instance Method Details
#call(node, context) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rexml/css_selector/queries/descendant_query.rb', line 19 def call(node, context) cache = context.cache result = nil while (node = context.adapter.get_parent_node(node)) cached = cache[[object_id, node.object_id]] if cached.nil? result ||= DeferredResult.new result.is_match = @cont.call(node, context) cache[[object_id, node.object_id]] = result return true if result.is_match else result&.is_match = cached.is_match return cached.is_match end end false end |