Class: RubyProf::CallInfoVisitor

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-prof/call_info_visitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(thread) ⇒ CallInfoVisitor

Returns a new instance of CallInfoVisitor.



22
23
24
# File 'lib/ruby-prof/call_info_visitor.rb', line 22

def initialize(thread)
  @thread = thread
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



20
21
22
# File 'lib/ruby-prof/call_info_visitor.rb', line 20

def block
  @block
end

#threadObject (readonly)

Returns the value of attribute thread.



20
21
22
# File 'lib/ruby-prof/call_info_visitor.rb', line 20

def thread
  @thread
end

Instance Method Details

#visit(&block) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/ruby-prof/call_info_visitor.rb', line 26

def visit(&block)
  @block = block

  self.thread.top_method.call_infos.each do |call_info|
    self.visit_call_info(call_info)
  end
end

#visit_call_info(call_info) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/ruby-prof/call_info_visitor.rb', line 34

def visit_call_info(call_info)
  self.block.call(call_info, :enter)
  call_info.children.each do |child|
    visit_call_info(child)
  end
  self.block.call(call_info, :exit)
end