Class: MethodCallTree

Inherits:
Object
  • Object
show all
Defined in:
lib/method_call_tree.rb,
lib/method_call_tree/version.rb

Constant Summary collapse

GET_ARGUMENTS =
<<-'TEXT'.freeze
  method(__method__).parameters.map { |_t, v|
    "#{v} = #{eval(v.to_s).inspect}"
  }.join(', ')
TEXT
SPACE_SIZE =
8
T_LINE =
'├─────'.freeze
I_LINE =
''.freeze
L_LINE =
'└─────'.freeze
VERSION =
'1.2.0'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ MethodCallTree

Returns a new instance of MethodCallTree.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/method_call_tree.rb', line 19

def initialize(options)
  @args = options[:args]
  @class = options[:class]
  @tree = {}
  @queue = []

  tracer.enable { yield }

  @tree.each do |root, tree|
    walk(root, tree)
  end
end

Class Method Details

.create(options = {}, &block) ⇒ Object



15
16
17
# File 'lib/method_call_tree.rb', line 15

def self.create(options = {}, &block)
  new(options, &block)
end

Instance Method Details

#to_sObject



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

def to_s
  @queue.join
end