Class: Querly::NodePair
- Inherits:
-
Object
- Object
- Querly::NodePair
- Defined in:
- lib/querly/node_pair.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #children ⇒ Object
-
#initialize(node:, parent: nil) ⇒ NodePair
constructor
A new instance of NodePair.
Constructor Details
#initialize(node:, parent: nil) ⇒ NodePair
Returns a new instance of NodePair.
6 7 8 9 |
# File 'lib/querly/node_pair.rb', line 6 def initialize(node:, parent: nil) @node = node @parent = parent end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
3 4 5 |
# File 'lib/querly/node_pair.rb', line 3 def node @node end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
4 5 6 |
# File 'lib/querly/node_pair.rb', line 4 def parent @parent end |
Instance Method Details
#children ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/querly/node_pair.rb', line 11 def children node.children.flat_map do |child| if child.is_a?(Parser::AST::Node) self.class.new(node: child, parent: self) else [] end end end |