Class: NodeQuery
- Inherits:
-
Object
- Object
- NodeQuery
- Defined in:
- lib/node_query.rb,
lib/node_query/version.rb
Defined Under Namespace
Modules: Compiler Classes: Adapter, Helper, MethodNotSupported, NodeRules, ParserAdapter, SyntaxTreeAdapter
Constant Summary collapse
- VERSION =
"1.13.10"
Class Method Summary collapse
-
.adapter ⇒ NodeQuery::Adapter
Get the adapter.
-
.configure(options) ⇒ Object
Configure NodeQuery.
Instance Method Summary collapse
-
#initialize(nql_or_ruls) ⇒ NodeQuery
constructor
Initialize a NodeQuery.
-
#match_node?(node) ⇒ Boolean
Check if the node matches the nql or rules.
-
#query_nodes(node, options = {}) ⇒ Array<Node>
Query matching nodes.
Constructor Details
Class Method Details
.adapter ⇒ NodeQuery::Adapter
Get the adapter
26 27 28 |
# File 'lib/node_query.rb', line 26 def self.adapter @adapter ||= ParserAdapter.new end |
.configure(options) ⇒ Object
Configure NodeQuery
20 21 22 |
# File 'lib/node_query.rb', line 20 def self.configure() @adapter = [:adapter] end |
Instance Method Details
#match_node?(node) ⇒ Boolean
Check if the node matches the nql or rules.
60 61 62 63 64 65 66 67 68 |
# File 'lib/node_query.rb', line 60 def match_node?(node) if @expression @expression.match_node?(node) elsif @rules @rules.match_node?(node) else false end end |
#query_nodes(node, options = {}) ⇒ Array<Node>
Query matching nodes.
47 48 49 50 51 52 53 54 55 |
# File 'lib/node_query.rb', line 47 def query_nodes(node, = {}) if @expression @expression.query_nodes(node, ) elsif @rules @rules.query_nodes(node, ) else [] end end |