Class: Node
- Inherits:
-
Object
- Object
- Node
- Defined in:
- lib/node.rb
Instance Method Summary collapse
- #addLink ⇒ Object
- #getID ⇒ Object
-
#initialize(num, name, type, value) ⇒ Node
constructor
A new instance of Node.
- #nodeData ⇒ Object
- #update(toadd) ⇒ Object
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
#addLink ⇒ Object
19 20 21 |
# File 'lib/node.rb', line 19 def addLink @linkcount += 1 end |
#getID ⇒ Object
15 16 17 |
# File 'lib/node.rb', line 15 def getID return @num end |
#nodeData ⇒ Object
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 |