るりまサーチ

最速Rubyリファレンスマニュアル検索!
82件ヒット [1-82件を表示] (0.143秒)
トップページ > クエリ:t[x] > クエリ:Ruby[x] > 種類:インスタンスメソッド[x] > クエリ:@[x] > クエリ:ruby[x] > クエリ:call[x] > クラス:TracePoint[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

TracePoint#callee_id -> Symbol | nil (9132.0)

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

...

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

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

t
race = TracePoint.new(:call) do |tp|
p [tp.method_id, tp.callee_id] # => [:method_name, :alias_name]
end
t
race.e...
...nable do
C.new.alias_name
end
//}

@
see TracePoint#method_id...

TracePoint#parameters -> [object] (6150.0)

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

...Method#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#event -> Symbol (6132.0)

発生したイベントの種類を Symbol で返します。

...は、TracePoint.new を参照してくださ
い。

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

//emlist[例][ruby]{
def foo(ret)
ret
end
t
race = TracePoint.new(:call, :return) do |tp|
p tp.event
end
t
race.enable
foo 1
# => :call
# :return
//}...

TracePoint#method_id -> Symbol | nil (6132.0)

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

...

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

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

t
race = TracePoint.new(:call) do |tp|
p [tp.method_id, tp.callee_id] # => [:method_name, :alias_name]
end
t
race.e...
...nable do
C.new.alias_name
end
//}

@
see TracePoint#callee_id...

TracePoint#path -> String (6126.0)

イベントが発生したファイルのパスを返します。

...トが発生したファイルのパスを返します。

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

//emlist[例][ruby]{
def foo(ret)
ret
end
t
race = TracePoint.new(:call) do |tp|
p tp.path # => "/path/to/test.rb"
end
t
race.enable
foo 1
//}...

絞り込み条件を変える

TracePoint#lineno -> Integer (3126.0)

発生したイベントの行番号を返します。

...発生したイベントの行番号を返します。

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

//emlist[例][ruby]{
def foo(ret)
ret
end
t
race = TracePoint.new(:call, :return) do |tp|
t
p.lineno
end
t
race.enable
foo 1
# => 1
# 3
//}...

TracePoint#self -> object (3126.0)

イベントを発生させたオブジェクトを返します。

...返します。

以下のようにする事で同じ値を取得できます。

なお、self メソッドは binding が nil になる :c_call および :c_return イベントに対しても正しく動作します。

//emlist[例][ruby]{
t
race.binding.eval('self')
//}

@
see TracePoint#binding...

TracePoint#defined_class -> Class | module (3074.0)

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

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

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

//emlist[例][ruby]{
modul...
...d; end
class C; include M; end;
t
race = 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
t
race = TracePoint.new(:call) do |tp|
p tp.defined_class # => #<Class:C>
end.enable do
C.foo
end
//}

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

@
see 50864...