Class: KQL::Query::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/kql/query.rb

Direct Known Subclasses

TopContext

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nodesObject

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

#nodesObject



32
33
34
# File 'lib/kql/query.rb', line 32

def nodes
  selected_nodes.map(&:node)
end

#top?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/kql/query.rb', line 44

def top?
  false
end