Class: FixtureFox::AstNode

Inherits:
Object
  • Object
show all
Defined in:
lib/fixture_fox/ast.rb

Direct Known Subclasses

Ast, AstElement, AstMember, AstTable

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#childrenObject (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

#parentObject (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

#typeObject

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

#dumpObject



22
23
24
25
# File 'lib/fixture_fox/ast.rb', line 22

def dump
  puts self.to_s
  indent { children.each(&:dump) }
end

#inspectObject



27
28
29
30
# File 'lib/fixture_fox/ast.rb', line 27

def inspect
  "#<#{self.class}:#{object_id} @type=#{type&.uid.inspect}>"
#     raise
end