Class: Node
- Inherits:
-
Object
- Object
- Node
- Defined in:
- lib/rdnode.rb
Instance Attribute Summary collapse
-
#tmp ⇒ Object
readonly
Returns the value of attribute tmp.
Instance Method Summary collapse
- #add_on_tree(idd, tree) ⇒ Object
- #depth ⇒ Object
- #id ⇒ Object
- #id=(x) ⇒ Object
-
#initialize(depth) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(depth) ⇒ Node
Returns a new instance of Node.
2 3 4 5 6 7 |
# File 'lib/rdnode.rb', line 2 def initialize(depth) @tmp = {} @depth = depth @tree = nil @id = nil end |
Instance Attribute Details
#tmp ⇒ Object (readonly)
Returns the value of attribute tmp.
8 9 10 |
# File 'lib/rdnode.rb', line 8 def tmp @tmp end |
Instance Method Details
#add_on_tree(idd, tree) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/rdnode.rb', line 29 def add_on_tree(idd, tree) tree.add_node(idd, self) @tree = tree @id = idd @depth = nil end |
#depth ⇒ Object
10 11 12 13 14 15 |
# File 'lib/rdnode.rb', line 10 def depth if @depth == nil return do_depth end @depth end |
#id ⇒ Object
17 18 19 |
# File 'lib/rdnode.rb', line 17 def id @id end |
#id=(x) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/rdnode.rb', line 21 def id=(x) if @tree == nil @id = x return end raise "Error can not call id=(#{x}) for this node." end |