るりまサーチ

最速Rubyリファレンスマニュアル検索!
106件ヒット [1-100件を表示] (0.186秒)
トップページ > クエリ:t[x] > クエリ:Ruby[x] > 種類:インスタンスメソッド[x] > クエリ:r[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

ライブラリ

キーワード

検索結果

<< 1 2 > >>

TracePoint#parameters -> [object] (15238.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#callee_id -> Symbol | nil (12120.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#inspect -> String (9226.0)

self の状態を人間に読みやすい文字列にして返します。

...self の状態を人間に読みやすい文字列にして返します。

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

TracePoint#path -> String (9220.0)

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

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

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

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

TracePoint#event -> Symbol (9126.0)

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

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

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

//emlist[例][ruby]{
def foo(ret)
r
et
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 (9120.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#lineno -> Integer (6220.0)

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

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

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

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

TracePoint#self -> object (6120.0)

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

...返します。

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

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

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

@see TracePoint#binding...

TracePoint#defined_class -> Class | module (6068.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...

TracePoint#binding -> Binding | nil (6026.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...は binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。

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

絞り込み条件を変える

TracePoint#binding -> Binding (6020.0)

発生したイベントによって生成された Binding オブジェクトを返します。

...発生したイベントによって生成された Binding オブジェクトを返します。


//emlist[例][ruby]{
def foo(ret)
r
et
end
t
race = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
t
race.enable
foo 1
//}...
<< 1 2 > >>