I think you can use Ruby stdlib Tracer.
I wrote the code in a file test.rb:
require 'tracer'
Tracer.on
class A
def square(a)
@b = a*a
result
end
def result
@b
end
end
a = A.new
puts a.square(5)
Tracer.off
Now run the code and see everything that happens under the hood:
(arup~>Ruby)$ ruby test.rb
25
(arup~>Ruby)$
. .
require 'tracer'
class A
def square(a)
@b = a*a
result
end
def result
@b
end
end
Tracer.on
a = A.new
puts a.square(5)
Tracer.off
, :
(arup~>Ruby)$ ruby test.rb
25
(arup~>Ruby)$