クラス定義をHTMLで

RubyのModuleクラスのインスタンス変数を使うと、クラス定義をリフレクトして出力できますね。
疑問: どうしてModule#public_class_methodsやModule#class_methodsがないのでしょうね。→id:sshiさんから、「クラス(モジュール)メソッドはクラス(モジュール)オブジェクトの特異メソッドなので、Object#singleton_methodsで取得できます」とコメントをいただきました。ありがとうございます。なかなか難しいですね。

class Array
  def add_as_html(title, names)
    if names.length > 0
      self << "<h2>#{title}</h2>"
      self << "<ul>"
      names.each { |name|
        self << "<li>#{name}</li>"
      }
      self << "</ul>"
    end
  end
end

class Module
  def html
    a = []
    a << "<h1>#{self}</h1>"
    a.add_as_html("Class Variables", class_variables)
    a.add_as_html("Constants", constants)
    a.add_as_html("Public Instance Methods", public_instance_methods)
    a.join("\n")
  end
end

class Rubyco
  @@classVar1 = 1
  CONST_CONST = 123
  def hello
    # ...
  end
end

puts Rubyco.html