Class: KQL::Query::Context
- Inherits:
-
Object
- Object
- KQL::Query::Context
- Defined in:
- lib/kql/query.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#selected_nodes ⇒ Object
Returns the value of attribute selected_nodes.
Instance Method Summary collapse
- #children(**kwargs) ⇒ Object
-
#initialize(selected_nodes) ⇒ Context
constructor
A new instance of Context.
- #nodes ⇒ Object
- #top? ⇒ Boolean
Constructor Details
#initialize(selected_nodes) ⇒ Context
Returns a new instance of Context.
28 29 30 |
# File 'lib/kql/query.rb', line 28 def initialize(selected_nodes) @selected_nodes = selected_nodes end |
Instance Attribute Details
#selected_nodes ⇒ Object
Returns the value of attribute selected_nodes.
26 27 28 |
# File 'lib/kql/query.rb', line 26 def selected_nodes @selected_nodes end |
Instance Method Details
#children(**kwargs) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/kql/query.rb', line 36 def children(**kwargs) nodes.flat_map do |node| node.children .each_with_index .map { |n, i| Query::SelectedNode.new(n, node.children, i, **kwargs) } end end |
#nodes ⇒ Object
32 33 34 |
# File 'lib/kql/query.rb', line 32 def nodes selected_nodes.map(&:node) end |
#top? ⇒ Boolean
44 45 46 |
# File 'lib/kql/query.rb', line 44 def top? false end |