るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 > >>

TracePoint#callee_id -> Symbol | nil (6144.0)

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

...した場合に発生します。

//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

trace.enable do
C.new.alias_name
end

//}

@see TracePoint#method_id...

TracePoint#defined_class -> Class | module (146.0)

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

...emlist[例][ruby]{
class C; 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 508...

TracePoint#parameters -> [object] (56.0)

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

...ror :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
.enab...
...le do
foo(1)
end

//}

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

TracePoint#method_id -> Symbol | nil (44.0)

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

...した場合に発生します。

//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

trace.enable do
C.new.alias_name
end

//}

@see TracePoint#callee_id...

TracePoint#binding -> Binding | nil (38.0)

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

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

//emlist[例][ruby]{
def foo(ret)
ret
end

trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end

trace.enable
foo 1
//}...

絞り込み条件を変える

TracePoint#event -> Symbol (38.0)

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

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

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

//emlist[例][ruby]{
def foo(ret)
ret
end

trace = TracePoint.new(:call, :return) do |tp|
p tp.event
end

trace.enable
foo 1
# => :call
# :return
/...

TracePoint#inspect -> String (38.0)

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

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

//emlist[例][ruby]{
def foo(ret)
ret
end

trace = TracePoint.new(:call) do |tp|
p tp.inspect # "#<TracePoint:call `foo'@/path/to/test.rb:1>"
end

trace.enable
foo 1
//}...

TracePoint#binding -> Binding (32.0)

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

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


//emlist[例][ruby]{
def foo(ret)
ret
end

trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end

trace.enable
foo 1
//}...

TracePoint#lineno -> Integer (32.0)

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

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

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

//emlist[例][ruby]{
def foo(ret)
ret
end

trace = TracePoint.new(:call, :return) do |tp|
tp.lineno
end

trace.enable
foo 1
# => 1
# 3
//}...

TracePoint#path -> String (32.0)

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

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

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

//emlist[例][ruby]{
def foo(ret)
ret
end

trace = TracePoint.new(:call) do |tp|
p tp.path # => "/path/to/test.rb"
end

trace.enable
foo 1
//}...

絞り込み条件を変える

<< 1 2 > >>