lineno

lineno() Instance Public methods Line number of the event

inspect

trace.inspect â string Instance Public methods Return a string containing a human-readable TracePoint status.

event

event() Instance Public methods Type of event See Events at TracePoint for more information.

enabled?

trace.enabled? â true or false Instance Public methods The current status of the trace

enable

trace.enable â true or falsetrace.enable { block } â obj Instance Public methods Activates the trace Return true if trace was enabled. Return false if trace was disabled. trace.enabled? #=> false trace.enable #=> false (previous state) # trace is enabled trace.enabled? #=> true trace.enable #=> true (previous state) # trace is still enabled If a block is given, the trace will only be enabled within the scope of

disable

trace.disable â true or falsetrace.disable { block } â obj Instance Public methods Deactivates the trace Return true if trace was enabled. Return false if trace was disabled. trace.enabled? #=> true trace.disable #=> false (previous status) trace.enabled? #=> false trace.disable #=> false If a block is given, the trace will only be disable within the scope of the block. trace.enabled? #=> true trace.disable do trace.ena

defined_class

defined_class() Instance Public methods Return class or module of the method being called. class C; def foo; end; end trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> C end.enable do C.new.foo end If method is defined by a module, then that module is returned. module M; def foo; end; end class C; include M; end; trace = TracePoint.new(:call) do |tp| p tp.defined_class #=> M end.enable do C.new.foo end Note: defined_class returns singleton class. 6th bloc

binding

binding() Instance Public methods Return the generated binding object from event

trace

TracePoint.trace(*events) { |obj| block } â obj Class Public methods A convenience method for ::new, that activates the trace automatically. trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] } #=> #<TracePoint:0x007f786a452448> trace.enabled? #=> true

new

TracePoint.new(*events) { |obj| block } â obj Class Public methods Returns a new TracePoint object, not enabled by default. Next, in order to activate the trace, you must use #enable trace = TracePoint.new(:call) do |tp| p [tp.lineno, tp.defined_class, tp.method_id, tp.event] end #=> #<TracePoint:0x007f17372cdb20> trace.enable #=> #<TracePoint:0x007f17372cdb20> puts "Hello, TracePoint!" # ... # [48, IRB::Notifier::AbstractNotifier, :printf, :call]