144件ヒット
[101-144件を表示]
(0.079秒)
クラス
- Module (48)
- TracePoint (12)
モジュール
- Kernel (84)
キーワード
- ancestors (12)
-
const
_ defined? (12) - constants (12)
-
defined
_ class (12) -
dir
_ config (12) -
enable
_ config (24) -
try
_ cpp (24) -
with
_ config (24)
検索結果
先頭4件
-
Module
# const _ defined?(name , inherit = true) -> bool (37.0) -
モジュールに name で指定される名前の定数が定義されている時真 を返します。
...クラスや include したモジュールで定義された定数を検索対象
にするかどうかは第二引数で制御することができます。
@param name String, Symbol で指定される定数名。
@param inherit false を指定するとスーパークラスや include したモ......はなりません。
//emlist[例][ruby]{
module Kernel
FOO = 1
end
# Object は include したモジュールの定数に対しても
# true を返す
p Object.const_defined?(:FOO) # => true
module Bar
BAR = 1
end
class Object
include Bar
end
# ユーザ定義のモジュールに対し......ても同様
p Object.const_defined?(:BAR) # => true
class Baz
include Bar
end
# Object 以外でも同様になった
# 第二引数のデフォルト値が true であるため
p Baz.const_defined?(:BAR) # => true
# 第二引数を false にした場合
p Baz.const_defined?(:BAR, false)... -
TracePoint
# defined _ class -> Class | module (25.0) -
メソッドを定義したクラスかモジュールを返します。
...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 d......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.#se... -
Module
# ancestors -> [Class , Module] (19.0) -
クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。
...先順位順に配列に格納して返します。
//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
p ancestors
p included_modules
p superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}
@see Module#included_modules... -
Module
# constants(inherit = true) -> [Symbol] (19.0) -
そのモジュール(またはクラス)で定義されている定数名の配列を返します。
...true を指定するとスーパークラスや include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables,...