[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Finding classes

Florian Frank

8/30/2006 2:57:00 PM

Marcus Bristav wrote:
> I need to find classes that either:
>
> 1) Includes a specific module
>
> or
>
> 2) Includes a specfic string in the class name

require 'enumerator'

ObjectSpace.enum_for(:each_object, Class).select { |x|
x.ancestors.include?(Module) }

ObjectSpace.enum_for(:each_object, Class).select { |x| x.name =~ /String/ }

--
Florian Frank