do you want to find all objects that belong to that class? you need to
use ObjectSpace for that:

ObjectSpace.each_object(classname) {|obj| do something}

the .each method in your class is for individual objects to provide
internal iterators (e.g. if you're implementing a collection class)

martin

On Wed, May 16, 2012 at 2:16 PM, Matt Mencel <MR-Mencel / wiu.edu> wrote:
> How do I iterate through a Class so that I can perform some action on eac=
h object? =A0For example...
>
> MyClass.each do {|obj| DO SOME STUFF}
>
>
> It looks like I have to create the .each method in my class. =A0I tried s=
omething like what's mentioned here...
> http://stackoverflow.com/questions/2080007/how-do-i-add-each-method-to-ru=
by-object-or-should-i-extend-array
>
> ...but haven't gotten it to work.
>
> Matt
>