24件ヒット
[1-24件を表示]
(0.121秒)
ライブラリ
- ビルトイン (24)
検索結果
先頭2件
-
Module
# class _ variables(inherit = true) -> [Symbol] (24221.0) -
クラス/モジュールに定義されているクラス変数の名前の配列を返します。
...y]{
class One
@@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables # => [:@@var1]
Two.class_variables # => [:@@var2, :@@var1]
Two.class_variables(false) # => [:@@var2]
//}
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_......variables, Module#constants... -
Module
# constants(inherit = true) -> [Symbol] (6114.0) -
そのモジュール(またはクラス)で定義されている定数名の配列を返します。
...ルードしているモジュールの定数も含みます。
Object のサブクラスの場合、Objectやそのスーパークラスで定義されている
定数は含まれません。 Object.constants とすると Object クラスで定義された
定数の配列が得られます。
得......include したモジュールで
定義された定数が対象にはなります。false を指定した場合 対象にはなりません。
@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables
//emlist[Module.constan......ts と Module#constants の違い][ruby]{
# 出力の簡略化のため起動時の定数一覧を取得して後で差し引く
$clist = Module.constants
class Foo
FOO = 1
end
class Bar
BAR = 1
# Bar は BAR を含む
p constants # => [:BAR]
# 出力に FOO は...