以下の内容はhttps://tbpgr.hatenablog.com/entry/20140714/1405340436より取得しました。


Ruby | Module | class_variables

概要

Module#class_variables -> [Symbol]

詳細

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

サンプルコード
require 'tbpgr_utils'

module Hogeable
  @@hoge = 1
end

class Hoge
  @@hoge = 2
end

class Hige
  @@hige = 3
  include Hogeable
end

class Hage
end

bulk_puts_eval binding, <<-EOS
Hoge.class_variables
Hige.class_variables
Hage.class_variables
EOS

__END__
下記はTbpgrUtils gemの機能
bulk_puts_eval

https://rubygems.org/gems/tbpgr_utils
https://github.com/tbpgr/tbpgr_utils

出力

出力

Hoge.class_variables # => [:@@hoge]
Hige.class_variables # => [:@@hige, :@@hoge]
Hage.class_variables # => []



以上の内容はhttps://tbpgr.hatenablog.com/entry/20140714/1405340436より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14