Class: Recursivar::Graph

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(heap) ⇒ Graph

Returns a new instance of Graph.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/recursivar/graph.rb', line 8

def initialize(heap)
  @graph = Macrocosm.new(curveness: 0.2)

  heap.each do |var|
    @graph.add_node(var.inspect, var.klass)

    var.values.each_pair do |name, ref_var|
      @graph.add_link(var.inspect, ref_var.inspect, relation_in_list: name, relation_in_graph: name)
    end

    var.callees && var.callees.each_pair do |level, callee|
      level = "-#{level}"
      @graph.add_link(var.inspect, callee.inspect, relation_in_list: level, relation_in_graph: level, line_style: {type: :dotted})
    end
  end
end

Instance Attribute Details

#heapObject (readonly)

Returns the value of attribute heap.



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

def heap
  @heap
end

Instance Method Details

#to_sObject



25
26
27
# File 'lib/recursivar/graph.rb', line 25

def to_s
  @graph.to_s
end