From: Robert Dober Date: 2007-07-25T17:37:44+09:00 Subject: Re: Help: Get list of modules which are included in the class On 7/25/07, Pe�a, Botp wrote: > On Behalf Of Chirag Mistry: > # only want a list which contains modules M1 and M2 for MyClass. If we > # call "MyClass.ancestors" which returns all the modules which > # are include directly or indirectly in this class and all parent class > > how about subtracting fr there =) > > something like, > > irb(main):026:0> C2.ancestors - (Class.new.ancestors + [C2]) > => [M2, M1] > > sorry if my answer sound stupid. > > kind regards -botp > not stupid at all, you just overlooked a little detail, parent classes. module M1; end module M2; end class C1; include M1 end class C2 < C1; include M2 end p C2.ancestors - (Class.new.ancestors + [C2]) Robert -- I always knew that one day Smalltalk would replace Java. I just didn't know it would be called Ruby -- Kent Beck