From: ts Date: 2003-01-04T02:23:55+09:00 Subject: Re: toplevel modules and classes >>>>> "E" == Eugene Scripnik writes: E> OK, another question. Module#constants return constants accessible E> in this module. But Class#constants produces the same output as E> Object.constants (Class itself is an Object, right?). How do I get all no, no you don't have the same output pigeon% ruby -e 'class A; B = C = 12; end; p (A.constants - Object.constants)' ["B", "C"] pigeon% E> modules and classes defined in this particular class? but you can't use this directly, because of this problem pigeon% ruby -e 'class A; B = A = 12; end; p (A.constants - Object.constants)' ["B"] pigeon% something like this (it's strange for me to put classes in another class, why do you want to do this ?) pigeon% cat b.rb #!/usr/bin/ruby class A class A; end class B; end end A.constants.each do |kl| a = A.const_get(kl) b = Object.const_defined?(kl) && Object.const_get(kl) puts a if a != b && a.kind_of?(Module) end pigeon% pigeon% b.rb A::A A::B pigeon% you must adapt it, if it's not a toplevel class Guy Decoux