class Class
def descendants
class D < C; end
C.descendants # => [B, A]
class A < B; end
C.descendants # => [B]
class B < C; end
C.descendants # => []
class C; end
Returns an array with all classes that are < than its receiver.
def descendants subclasses.concat(subclasses.flat_map(&:descendants)) end