title: How can I get all defined classes?
body: <p>Is there a way to get the list of all defined classes. I'm looking for a code like this:</p>
  
  
  
  <pre class="lang-ruby prettyprint-override"><code>Class.instances.each do |klass|
    puts klass.name
  end
  </code></pre>
  
  <p>If there is no way to do this. It is possible to define a class A such that its descendants are registered in it? For example in this way:</p>
  
  <pre class="lang-ruby prettyprint-override"><code>class A
    ...
  end
  
  class B &lt; A
  end
  
  class C &lt; B
  end
  
  A.descendants   # =&gt; [B, C] 
  </code></pre>