Class: Junoser::RuleTree::Node
- Inherits:
-
Object
- Object
- Junoser::RuleTree::Node
- Defined in:
- lib/junoser/rule_tree/node.rb
Constant Summary collapse
- INDENT =
' '
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<<(child) ⇒ Object
-
#initialize(name) ⇒ Node
constructor
A new instance of Node.
- #print(level = 0) ⇒ Object
Constructor Details
#initialize(name) ⇒ Node
Returns a new instance of Node.
9 10 11 12 |
# File 'lib/junoser/rule_tree/node.rb', line 9 def initialize(name) @name = name @children = [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
7 8 9 |
# File 'lib/junoser/rule_tree/node.rb', line 7 def children @children end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/junoser/rule_tree/node.rb', line 7 def name @name end |
Instance Method Details
#<<(child) ⇒ Object
14 15 16 |
# File 'lib/junoser/rule_tree/node.rb', line 14 def <<(child) @children << child end |
#print(level = 0) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/junoser/rule_tree/node.rb', line 18 def print(level = 0) puts (INDENT * level) + "- #{@name}" @children.each do |child| child.print level + 1 end end |