Class: FixtureFox::AstNode
- Inherits:
-
Object
- Object
- FixtureFox::AstNode
- Defined in:
- lib/fixture_fox/ast.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
List of elements or members.
-
#parent ⇒ Object
readonly
Parent node.
-
#type ⇒ Object
Type of this node or of the node referenced by this node.
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(parent) ⇒ AstNode
constructor
A new instance of AstNode.
- #inspect ⇒ Object
Constructor Details
#initialize(parent) ⇒ AstNode
Returns a new instance of AstNode.
16 17 18 19 20 |
# File 'lib/fixture_fox/ast.rb', line 16 def initialize(parent) @parent = parent @children = [] @parent.children << self if @parent end |
Instance Attribute Details
#children ⇒ Object (readonly)
List of elements or members. Only non-empty for table and records nodes. Assigned by the parser
10 11 12 |
# File 'lib/fixture_fox/ast.rb', line 10 def children @children end |
#parent ⇒ Object (readonly)
Parent node. nil for the top-level Ast node
6 7 8 |
# File 'lib/fixture_fox/ast.rb', line 6 def parent @parent end |
#type ⇒ Object
Type of this node or of the node referenced by this node. nil for the top-level Ast node. Assigned by the analyzer
14 15 16 |
# File 'lib/fixture_fox/ast.rb', line 14 def type @type end |
Instance Method Details
#dump ⇒ Object
22 23 24 25 |
# File 'lib/fixture_fox/ast.rb', line 22 def dump puts self.to_s indent { children.each(&:dump) } end |
#inspect ⇒ Object
27 28 29 30 |
# File 'lib/fixture_fox/ast.rb', line 27 def inspect "#<#{self.class}:#{object_id} @type=#{type&.uid.inspect}>" # raise end |