From: Ryan Davis Date: 2010-02-02T06:38:56+09:00 Subject: Re: Module children On Feb 1, 2010, at 13:06 , Aaron Patterson wrote: > On Tue, Feb 02, 2010 at 04:50:34AM +0900, Camille Roux wrote: >> Hello, >> >> I'd like to get the list of all the classes contained in a module. >> What's the simple way to do that? > >>> module Foo; A = 1; class B; end; module C; end end > => nil >>> Foo.constants.find_all { |k| Class === Foo.const_get(k) } > => ["B"] Personally, I usually map first: >> Foo.constants.map { |s| Foo.const_get s }.find_all { |k| Class === k } => [Foo::B]