Ruby 3.2 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Moduleクラス > class_variables
class_variables(inherit = true) -> [Symbol]
[permalink][rdoc]クラス/モジュールに定義されているクラス変数の名前の配列を返します。
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_ALSO] Module.constants, Kernel.#local_variables, Kernel.#global_variables, Object#instance_variables, Module#constants