Class: Recursivar::Heap::Value

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Value

Returns a new instance of Value.



8
9
10
11
12
# File 'lib/recursivar/heap.rb', line 8

def initialize(obj)
  @obj = obj
  @values = {}
  @callees = nil
end

Instance Attribute Details

#calleesObject (readonly)

Returns the value of attribute callees.



6
7
8
# File 'lib/recursivar/heap.rb', line 6

def callees
  @callees
end

#objObject (readonly)

Returns the value of attribute obj.



6
7
8
# File 'lib/recursivar/heap.rb', line 6

def obj
  @obj
end

#valuesObject (readonly)

Returns the value of attribute values.



6
7
8
# File 'lib/recursivar/heap.rb', line 6

def values
  @values
end

Instance Method Details

#add_callee(callee, level) ⇒ Object



32
33
34
# File 'lib/recursivar/heap.rb', line 32

def add_callee(callee, level)
  (@callees ||= {})[level] = callee
end

#inspectObject



14
15
16
# File 'lib/recursivar/heap.rb', line 14

def inspect
  @inspect ||= "#{klass}:#{@obj.object_id}"
end

#klassObject



18
19
20
# File 'lib/recursivar/heap.rb', line 18

def klass
  @klass ||= @obj.class
end

#ref_instance_variables(heap) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/recursivar/heap.rb', line 22

def ref_instance_variables(heap)
  return if @referred
  @referred = true

  obj.instance_variables.each do |name|
    value = obj.instance_variable_get(name)
    @values[name] = heap.ref(value)
  end
end