るりまサーチ

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

別のキーワード

  1. class inherited
  2. _builtin inherited
  3. inherited _builtin
  4. rb_class_inherited

ライブラリ

クラス

検索結果

Class#inherited(subclass) -> () (27256.0)

クラスのサブクラスが定義された時、新しく生成されたサブクラスを引数 にインタプリタから呼び出されます。このメソッドが呼ばれるタイミングは クラス定義文の実行直前です。

...class プログラム内で新たに定義された自身のサブクラスです。

//emlist[例][ruby]{
class
Foo
def Foo.inherited(subclass)
puts "class \"#{self}\" was inherited by \"#{subclass}\""
end
end
class
Bar < Foo
puts "executing class body"
end

# => class "Foo" was inherited...
...by "Bar"
# executing class body
//}...

Object#singleton_methods(inherited_too = true) -> [Symbol] (222.0)

そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。

...返します。

inherited
_too が真のときは継承した特異メソッドを含みます。
継承した特異メソッドとは Object#extend によって追加された特異メソッドや、
self がクラスの場合はスーパークラスのクラスメソッド(Classのインスタン...
...@param inherited_too 継承した特異メソッドを含める場合は真を、
そうでない場合は偽を指定します。

//emlist[例1][ruby]{
Parent = Class.new

class
<<Parent
private; def private_class_parent() end
protected; def protected_class_parent() en...
...d
public; def public_class_parent() end
end

Foo = Class.new(Parent)

class
<<Foo
private; def private_class_foo() end
protected; def protected_class_foo() end
public; def public_class_foo() end
end

module Bar
private; def private_bar() end
protected; def protected_bar() end...

Module#const_source_location(name, inherited = true) -> [String, Integer] (126.0)

name で指定した定数の定義を含むソースコードのファイル名と行番号を配列で返します。

...スコードのファイル名と行番号を配列で返します。

@param name Symbol,String で定数の名前を指定します。
@param inherited true を指定するとスーパークラスや include したモジュールで定義された定数が対象にはなります。false を指...
...った場合は空の配列を返します。

//emlist[例][ruby]{
# test.rb:
class
A # line 1
C1 = 1
C2 = 2
end

module M # line 6
C3 = 3
end

class
B < A # line 10
include M
C4 = 4
end

class
A # 継続して A を定義する
C2 = 8 # 定数を再定義する
end...

Module#instance_methods(inherited_too = true) -> [Symbol] (126.0)

そのモジュールで定義されている public および protected メソッド名 の一覧を配列で返します。

...tected メソッド名
の一覧を配列で返します。

@param inherited_too false を指定するとそのモジュールで定義されているメソッドのみ返します。

@see Object#methods

//emlist[例1][ruby]{
class
Foo
private; def private_foo() end
protected; def protect...
...vate_instance_methods(false)
p Foo.protected_instance_methods(false)

class
Bar < Foo
end
//}

実行結果

[:protected_foo, :public_foo]
[:public_foo]
[:private_foo]
[:protected_foo]

//emlist[例2][ruby]{
class
Bar
private; def private_foo() end
protected; def protecte...

Object#methods(include_inherited = true) -> [Symbol] (126.0)

そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。

...


@param include_inherited 引数が偽の時は Object#singleton_methods(false) と同じになります。

//emlist[例1][ruby]{
class
Parent
private; def private_parent() end
protected; def protected_parent() end
public; def public_parent() end
end

class
Foo < Parent
priva...
...te; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end

obj = Foo.new
class
<<obj
private; def private_singleton() end
protected; def protected_singleton() end
public; def public_singleton() end
end

# あるオブジェク...

絞り込み条件を変える

Thread#add_trace_func(pr) -> Proc (37.0)

スレッドにトレース用ハンドラを追加します。

...d.new do
class
Trace
end
43.to_s
end
th.add_trace_func lambda {|*arg| p arg }
th.join

# => ["line", "example.rb", 4, nil, #<Binding:0x00007f98e107d0d8>, nil]
# => ["c-call", "example.rb", 4, :inherited, #<Binding:0x00007f98e1087448>, Class]
# => ["c-return", "example.rb", 4, :inherited, #<Bin...
...ding:0x00007f98e1085d00>, Class]
# => ["class", "example.rb", 4, nil, #<Binding:0x00007f98e108f210>, nil]
# => ["end", "example.rb", 5, nil, #<Binding:0x00007f98e108e5e0>, nil]
# => ["line", "example.rb", 6, nil, #<Binding:0x00007f98e108d4b0>, nil]
# => ["c-call", "example.rb", 6, :to_s, #<Binding:0...

Thread#set_trace_func(pr) -> Proc | nil (37.0)

スレッドにトレース用ハンドラを設定します。

...ad.new do
class
Trace
end
2.to_s
Thread.current.set_trace_func nil
3.to_s
end
th.set_trace_func lambda {|*arg| p arg }
th.join

# => ["line", "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited, #<Binding:0x00007fc8de886770>, Class]
# => ["...
...c-return", "example.rb", 2, :inherited, #<Binding:0x00007fc8de8844e8>, Class]
# => ["class", "example.rb", 2, nil, #<Binding:0x00007fc8de88e830>, nil]
# => ["end", "example.rb", 3, nil, #<Binding:0x00007fc8de88d6b0>, nil]
# => ["line", "example.rb", 4, nil, #<Binding:0x00007fc8de88c440>, nil]
# => [...