Class: Node

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

Direct Known Subclasses

Link, Tag, Text

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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

#depthObject



10
11
12
13
14
15
# File 'lib/rdnode.rb', line 10

def depth
  if @depth == nil
    return do_depth
  end
  @depth
end

#idObject



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