D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
TracePoint
/
Filename :
enable-i.ri
back
Copy
U:RDoc::AnyMethod[iI"enable:ETI"TracePoint#enable;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"Activates the trace.;To:RDoc::Markup::BlankLine o; ; [I".Returns +true+ if the trace was enabled. ;TI"/Returns +false+ if the trace was disabled.;T@o:RDoc::Markup::Verbatim; [I"trace.enabled? #=> false ;TI"0trace.enable #=> false (previous state) ;TI"* # trace is enabled ;TI"trace.enabled? #=> true ;TI"/trace.enable #=> true (previous state) ;TI"0 # trace is still enabled ;T:@format0o; ; [I"UIf a block is given, the trace will only be enabled during the block execution. ;TI"MIf target and target_line are both nil, then target_thread will default ;TI"/to the current thread if a block is given.;T@o;; [ I"trace.enabled? #=> false ;TI" ;TI"trace.enable do ;TI" trace.enabled? ;TI"0 # Only enabled for this block and thread ;TI" end ;TI" ;TI"trace.enabled? #=> false ;T; 0o; ; [ I"MThe +target+, +target_line+, and +target_thread+ parameters are used to ;TI"Climit tracing to specified code objects. +target+ should be a ;TI"Fcode object for which RubyVM::InstructionSequence.of will return ;TI"an instruction sequence.;T@o;; [I"-t = TracePoint.new(:line) { |tp| p tp } ;TI" ;TI"def m1 ;TI" p 1 ;TI" end ;TI" ;TI"def m2 ;TI" p 2 ;TI" end ;TI" ;TI"#t.enable(target: method(:m1)) ;TI" ;TI"m1 ;TI"3# Prints #<TracePoint:line test.rb:4 in `m1'> ;TI"m2 ;TI"# Prints nothing ;T; 0o; ; [I"CNote: You cannot access event hooks within the +enable+ block.;T@o;; [I""trace.enable { p tp.lineno } ;TI"*#=> RuntimeError: access from outside;T; 0: @fileI"trace_point.rb;T:0@omit_headings_from_table_of_contents_below0I"�trace.enable(target: nil, target_line: nil, target_thread: nil) -> true or false trace.enable(target: nil, target_line: nil, target_thread: :default) { block } -> obj ;T0[ I"=(target: nil, target_line: nil, target_thread: :default);T@IFI"TracePoint;TcRDoc::NormalClass00