るりまサーチ

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

別のキーワード

  1. _builtin >
  2. bigdecimal >
  3. comparable >
  4. module >
  5. integer >

ライブラリ

検索結果

Module#class_variables(inherit = true) -> [Symbol] (18233.0)

クラス/モジュールに定義されているクラス変数の名前の配列を返します。

...1 = 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#con...

Module#constants(inherit = true) -> [Symbol] (126.0)

そのモジュール(またはクラス)で定義されている定数名の配列を返します。

...@see Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#class_variables

//emlist[Module.constants と Module#constants の違い][ruby]{
# 出力の簡略化のため起動時の定数一覧を取得して後で差し引く
$clist = Module.const...
...O = 1
end

class Bar
BAR = 1

# Bar は BAR を含む
p constants # => [:BAR]
# 出力に FOO は含まれない
p Module.constants - $clist # => [:BAR, :Bar, :Foo]
class Baz
# Baz は定数を含まない
p constants # => []...
...# ネストしたクラスでは、外側のクラスで定義した定数は
# 参照可能なので、BAR は、Module.constants には含まれる
# (クラス Baz も Bar の定数なので同様)
p Module.constants - $clist # => [:BAR, :Baz, :Foo, :Bar]
end

end

//}...