Class: HNode
- Inherits:
-
Object
- Object
- HNode
- Defined in:
- lib/hengine/hmalloc.rb
Instance Attribute Summary collapse
-
#childNodes ⇒ Object
readonly
Returns the value of attribute childNodes.
-
#createTimestamp ⇒ Object
readonly
Returns the value of attribute createTimestamp.
-
#obj ⇒ Object
readonly
Returns the value of attribute obj.
-
#parentNode ⇒ Object
readonly
Returns the value of attribute parentNode.
-
#updateTimestamp ⇒ Object
Returns the value of attribute updateTimestamp.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(obj, parentNode = nil, timestamp = Time.now.to_i) ⇒ HNode
constructor
A new instance of HNode.
- #show(oid: nil, margin: 0) ⇒ Object
- #showObj(margin: 0) ⇒ Object
- #showTree(oid: nil, margin: 0) ⇒ Object
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, = Time.now.to_i) @obj = obj @createTimestamp = @updateTimestamp = @parentNode = parentNode @childNodes = [] end |
Instance Attribute Details
#childNodes ⇒ Object (readonly)
Returns the value of attribute childNodes.
5 6 7 |
# File 'lib/hengine/hmalloc.rb', line 5 def childNodes @childNodes end |
#createTimestamp ⇒ Object (readonly)
Returns the value of attribute createTimestamp.
5 6 7 |
# File 'lib/hengine/hmalloc.rb', line 5 def createTimestamp @createTimestamp end |
#obj ⇒ Object (readonly)
Returns the value of attribute obj.
5 6 7 |
# File 'lib/hengine/hmalloc.rb', line 5 def obj @obj end |
#parentNode ⇒ Object (readonly)
Returns the value of attribute parentNode.
5 6 7 |
# File 'lib/hengine/hmalloc.rb', line 5 def parentNode @parentNode end |
#updateTimestamp ⇒ Object
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 |