るりまサーチ

最速Rubyリファレンスマニュアル検索!
161件ヒット [1-100件を表示] (0.066秒)

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. range end

クラス

キーワード

検索結果

<< 1 2 > >>

TracePoint#enable -> bool (18140.0)

self のトレースを有効にします。

...racePoint#enabled? を返します。(トレースが既に有効であっ
た場合は true を返します。そうでなければ false を返します)

//emlist[例][ruby]{
trace.enabled? # => false
trace.enable # => false (実行前の状態)

# トレースが有効

trace.enabled? # =>...
...rue
trace.enable # => true (実行前の状態)

# 引き続きトレースが有効
//}

ブロックが与えられた場合、ブロック内でのみトレースが有効になります。
この場合はブロックの評価結果を返します。

//emlist[例][ruby]{
trace.enabled? # =>...
...false

trace.enable do
trace.enabled? # => true
end


trace.enabled? # => false
//}

[注意] イベントフックのためのメソッドにブロックの外側で参照した場合は
RuntimeError が発生する事に注意してください。

//emlist[例][ruby]{
trace.enable { p trace.li...

TracePoint#enable { ... } -> object (18140.0)

self のトレースを有効にします。

...racePoint#enabled? を返します。(トレースが既に有効であっ
た場合は true を返します。そうでなければ false を返します)

//emlist[例][ruby]{
trace.enabled? # => false
trace.enable # => false (実行前の状態)

# トレースが有効

trace.enabled? # =>...
...rue
trace.enable # => true (実行前の状態)

# 引き続きトレースが有効
//}

ブロックが与えられた場合、ブロック内でのみトレースが有効になります。
この場合はブロックの評価結果を返します。

//emlist[例][ruby]{
trace.enabled? # =>...
...false

trace.enable do
trace.enabled? # => true
end


trace.enabled? # => false
//}

[注意] イベントフックのためのメソッドにブロックの外側で参照した場合は
RuntimeError が発生する事に注意してください。

//emlist[例][ruby]{
trace.enable { p trace.li...

TracePoint#defined_class -> Class | module (104.0)

メソッドを定義したクラスかモジュールを返します。

...def foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => C
end
.enable do
C.new.foo
end

//}

メソッドがモジュールで定義されていた場合も(include に関係なく)モジュー
ルを返します。

//emlist[例][ruby]{
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

//}

[注意] 特異メソッドを実行した場合は TracePoint#defined_class は特異クラ
スを返します。また、Kernel.#set_trace_func の 6 番目のブロックパ
...
...く元のクラスを返します。

//emlist[例][ruby]{
class C; def self.foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => #<Class:C>
end
.enable do
C.foo
end

//}

Kernel.#set_trace_func と TracePoint の上記の差分に注意して
ください。

@
see 50864...

TracePoint.new(*events) {|obj| ... } -> TracePoint (66.0)

新しい TracePoint オブジェクトを作成して返します。トレースを有効 にするには TracePoint#enable を実行してください。

...
にするには TracePoint#enable を実行してください。

//emlist[例:irb で実行した場合][ruby]{
trace = TracePoint.new(:call) do |tp|
p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
end

# => #<TracePoint:0x007f17372cdb20>

trace.enable
# => false

puts "Hello, TraceP...
...t[][ruby]{
trace.disable
//}

@
param events トレースするイベントを String か Symbol で任
意の数指定します。

: :line

式の評価。

: :class

クラス定義、特異クラス定義、モジュール定義への突入。

: :end

クラス定義、特...
...の開始。

: :thread_end

スレッドの終了。



指定イベントに関連しない情報を取得するメソッドを実行した場合には
RuntimeError が発生します。

//emlist[例][ruby]{
TracePoint.trace(:line) do |tp|
p tp.raised_exception
end

# => RuntimeError: 'raise...
...の発生。

: :b_call

ブロックの開始。

: :b_return

ブロックの終了。

: :thread_begin

スレッドの開始。

: :thread_end

スレッドの終了。

: :fiber_switch

ファイバーの切り替え。


指定イベントに関連しない情報を取得するメソ...
...の発生。

: :b_call

ブロックの開始。

: :b_return

ブロックの終了。

: :thread_begin

スレッドの開始。

: :thread_end

スレッドの終了。

: :fiber_switch

ファイバーの切り替え。

: :script_compiled

スクリプトのコンパイル

指定...

TracePoint#callee_id -> Symbol | nil (44.0)

イベントが発生したメソッドの呼ばれた名前を Symbol で返します。 トップレベルであった場合は nil を返します。

...す。

@
raise RuntimeError イベントフックの外側で実行した場合に発生します。

//emlist[][ruby]{
class C
def method_name
end

alias alias_name method_name
end


trace = TracePoint.new(:call) do |tp|
p [tp.method_id, tp.callee_id] # => [:method_name, :alias_name]
end

trac...
...e.enable do
C.new.alias_name
end

//}

@
see TracePoint#method_id...

絞り込み条件を変える

TracePoint#method_id -> Symbol | nil (44.0)

イベントが発生したメソッドの定義時の名前を Symbol で返します。 トップレベルであった場合は nil を返します。

...す。

@
raise RuntimeError イベントフックの外側で実行した場合に発生します。

//emlist[][ruby]{
class C
def method_name
end

alias alias_name method_name
end


trace = TracePoint.new(:call) do |tp|
p [tp.method_id, tp.callee_id] # => [:method_name, :alias_name]
end

trac...
...e.enable do
C.new.alias_name
end

//}

@
see TracePoint#callee_id...

TracePoint#parameters -> [object] (38.0)

現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。

...parameters と同じです。

@
raise RuntimeError :call、:return、:b_call、:b_return、:c_call、:c_return
イベントのためのイベントフックの外側で実行した場合に発生します。

//emlist[例][ruby]{
def foo(a, b = 2)
end

TracePoint.new(:call) do |tp...
...|
p tp.parameters # => a], [:opt, :b
end
.enable do
foo(1)
end

//}

@
see Method#parameters, UnboundMethod#parameters, Proc#parameters...

TracePoint#disable -> bool (26.0)

self のトレースを無効にします。

...実行前の TracePoint#enabled? を返します。(トレースが既に有効であっ
た場合は true を返します。そうでなければ false を返します)

//emlist[例][ruby]{
trace.enabled? # => true
trace.disable # => false (実行前の状態)
trace.enabled? # => false
trace.disa...
...trace.enabled? # => true

trace.disable do
trace.enabled? # => false
end


trace.enabled? # => true
//}

[注意] イベントフックのためのメソッドに、ブロックの外側で参照した場合は
RuntimeError が発生する事に注意してください。

trace.enable { p t...
...race.lineno }
# => RuntimeError: access from outside

@
see TracePoint#enable, TracePoint#enabled?...

TracePoint#disable { ... } -> object (26.0)

self のトレースを無効にします。

...実行前の TracePoint#enabled? を返します。(トレースが既に有効であっ
た場合は true を返します。そうでなければ false を返します)

//emlist[例][ruby]{
trace.enabled? # => true
trace.disable # => false (実行前の状態)
trace.enabled? # => false
trace.disa...
...trace.enabled? # => true

trace.disable do
trace.enabled? # => false
end


trace.enabled? # => true
//}

[注意] イベントフックのためのメソッドに、ブロックの外側で参照した場合は
RuntimeError が発生する事に注意してください。

trace.enable { p t...
...race.lineno }
# => RuntimeError: access from outside

@
see TracePoint#enable, TracePoint#enabled?...

TracePoint#eval_script -> String | nil (26.0)

script_compiledイベント発生時にコンパイルされたソースコードを返します。 ファイルから読み込んだ場合は、nilを返します。

...、nilを返します。

//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.eval_script # => "puts 'hello'"
end
.enable do
eval("puts 'hello'")
end

//}

@
raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した...

絞り込み条件を変える

<< 1 2 > >>