Class: Node

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

Instance Method Summary collapse

Constructor Details

#initialize(num, name, type, value) ⇒ Node

Returns a new instance of Node.



2
3
4
5
6
7
8
9
# File 'lib/node.rb', line 2

def initialize(num, name, type, value)
  @num = num
  @name = name
  @type = type
  @linkcount = 0
  @value = Array.new
  @value.push(value)
end

Instance Method Details



19
20
21
# File 'lib/node.rb', line 19

def addLink
  @linkcount += 1
end

#getIDObject



15
16
17
# File 'lib/node.rb', line 15

def getID
  return @num
end

#nodeDataObject



23
24
25
# File 'lib/node.rb', line 23

def nodeData
  json_hash = {:id => @name, :type => @type, :linkcount => @linkcount, :data => @value}
end

#update(toadd) ⇒ Object



11
12
13
# File 'lib/node.rb', line 11

def update(toadd)
  @value.push(toadd)
end