From: black eyes Date: 2008-08-21T23:46:10+09:00 Subject: Re: Find all subclasses of a class/module the following are code in http://gist.github.com/6560 class Module def subclasses classes = [] ObjectSpace.each_object do |klass| next unless Module === klass classes << klass if self > klass end classes end end I think the above code is good! but considering the class and module are referenced by constants in ruby, use Module.constants is more naturally! the following are mine! the key is to get rid of the real constant such as PI and so on. def find_children p_klass Module.constants.find_all{|c_klass| c_klass!=c_klass.upcase ? p_klass > (Object.const_get c_klass) : nil} end # test! class MyString < String end puts find_children( String) #=> MyString require 'benchmark' include Benchmark puts find_children(Benchmark).include?(Tms) #=> fase puts Tms.name #=> Benchmark::Tms puts find_children(Benchmark).include?("Tms") #=> true -- Posted via http://www.ruby-forum.com/.