Ruby 4.1 リファレンスマニュアル

instance method Module#class_variables

class_variables(inherit = true) -> [Symbol][permalink][rdoc][edit]

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

[PARAM] inherit:
false を指定しない場合はスーパークラスやインクルードしているモジュールのクラス変数を含みます。
class One
  @@var1 = 1
end
class Two < One
  @@var2 = 2
end
p One.class_variables        # => [:@@var1]
p Two.class_variables        # => [:@@var2, :@@var1]
p Two.class_variables(false) # => [:@@var2]

[SEE_ALSO] Module.constants, Kernel?.local_variables, Kernel?.global_variables, Object#instance_variables, Module#constants