Class: Wongi::Engine::BetaNode
- Inherits:
-
Object
- Object
- Wongi::Engine::BetaNode
show all
- Includes:
- CoreExt
- Defined in:
- lib/wongi-engine/beta/beta_node.rb
Defined Under Namespace
Modules: TokenContainer
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from CoreExt
included
Constructor Details
#initialize(parent = nil) ⇒ BetaNode
Returns a new instance of BetaNode.
33
34
35
36
37
38
39
|
# File 'lib/wongi-engine/beta/beta_node.rb', line 33
def initialize parent = nil
@parent = parent
@children = []
if parent
parent.children << self
end
end
|
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
30
31
32
|
# File 'lib/wongi-engine/beta/beta_node.rb', line 30
def children
@children
end
|
#parent ⇒ Object
Returns the value of attribute parent.
29
30
31
|
# File 'lib/wongi-engine/beta/beta_node.rb', line 29
def parent
@parent
end
|
#rete ⇒ Object
53
54
55
56
57
|
# File 'lib/wongi-engine/beta/beta_node.rb', line 53
def rete
@rete ||= if parent
parent.rete
end
end
|
Instance Method Details
#assignment_node(variable, body) ⇒ Object
66
67
68
69
70
|
# File 'lib/wongi-engine/beta/beta_node.rb', line 66
def assignment_node variable, body
node = AssignmentNode.new self, variable, body
node.refresh
node
end
|
#depth ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/wongi-engine/beta/beta_node.rb', line 45
def depth
@depth ||= if parent.nil?
0
else
parent.depth + 1
end
end
|
#refresh ⇒ Object
72
73
74
|
# File 'lib/wongi-engine/beta/beta_node.rb', line 72
def refresh
parent.refresh_child self
end
|
#refresh_child(node) ⇒ Object
76
77
78
|
# File 'lib/wongi-engine/beta/beta_node.rb', line 76
def refresh_child node
raise "#{self.class} must implement refresh_child"
end
|
#root? ⇒ Boolean
41
42
43
|
# File 'lib/wongi-engine/beta/beta_node.rb', line 41
def root?
parent.nil?
end
|