るりまサーチ

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

別のキーワード

  1. _builtin to_r
  2. open3 pipeline_r
  3. matrix elements_to_r
  4. etc sc_getgr_r_size_max
  5. etc sc_getpw_r_size_max

ライブラリ

クラス

検索結果

TracePoint#defined_class -> Class | module (24228.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...
...e M; def foo; end; 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...