Class: HNode

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj, parentNode = nil, timestamp = Time.now.to_i) ⇒ HNode

Returns a new instance of HNode.



8
9
10
11
12
13
14
# File 'lib/hengine/hmalloc.rb', line 8

def initialize(obj, parentNode = nil, timestamp = Time.now.to_i)
  @obj = obj
  @createTimestamp = timestamp
  @updateTimestamp = timestamp
  @parentNode = parentNode 
  @childNodes = []
end

Instance Attribute Details

#childNodesObject (readonly)

Returns the value of attribute childNodes.



5
6
7
# File 'lib/hengine/hmalloc.rb', line 5

def childNodes
  @childNodes
end

#createTimestampObject (readonly)

Returns the value of attribute createTimestamp.



5
6
7
# File 'lib/hengine/hmalloc.rb', line 5

def createTimestamp
  @createTimestamp
end

#objObject (readonly)

Returns the value of attribute obj.



5
6
7
# File 'lib/hengine/hmalloc.rb', line 5

def obj
  @obj
end

#parentNodeObject (readonly)

Returns the value of attribute parentNode.



5
6
7
# File 'lib/hengine/hmalloc.rb', line 5

def parentNode
  @parentNode
end

#updateTimestampObject

Returns the value of attribute updateTimestamp.



6
7
8
# File 'lib/hengine/hmalloc.rb', line 6

def updateTimestamp
  @updateTimestamp
end

Class Method Details

.showObj(obj: nil, margin: 0) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/hengine/hmalloc.rb', line 16

def self.showObj(obj: nil, margin: 0)
  if obj.class == Hash
    hl.<< ' ' * margin + "  => by connect: receiver: #{obj[:receiver].class} - method: #{obj[:method]}(#{obj[:args]})".green, "DEBUG2"
  elsif 
    hl.<< ' ' * margin + "  => by hm().malloc: #{obj}".green, "DEBUG2"
  end
end

Instance Method Details

#show(oid: nil, margin: 0) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/hengine/hmalloc.rb', line 28

def show(oid: nil, margin: 0)
  
  parentObj = @parentNode.obj if @parentNode
  poid = parentObj.object_id if parentObj
  str = "oid: #{oid} - #{@obj.class} - parent: #{parentObj.class} => poid: #{poid} - time: #{Time.at(@updateTimestamp).to_time.strftime("%H:%M:%S")}"

  if poid
    hl.<< ' ' * margin + str.yellow, "DEBUG2"
  else
    hl.<< ' ' * margin + str.red, "DEBUG2"
  end
  
  self.showObj(margin: margin)

end

#showObj(margin: 0) ⇒ Object



24
25
26
# File 'lib/hengine/hmalloc.rb', line 24

def showObj(margin: 0)
  HNode.showObj(obj: @obj, margin: margin)
end

#showTree(oid: nil, margin: 0) ⇒ Object



44
45
46
47
48
49
# File 'lib/hengine/hmalloc.rb', line 44

def showTree(oid: nil, margin: 0)
  self.show(oid: oid, margin: margin)
  @childNodes.each do |node|
    node.showTree(margin: margin + 3)
  end
end