1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add Class#subclasses

Implements [Feature #18273]

Returns an array containing the receiver's direct subclasses without
singleton classes.
This commit is contained in:
Jean Boussier 2021-10-28 14:07:11 +02:00
parent a88b19d3d0
commit c0c2b31a35
Notes: git 2021-11-23 19:49:51 +09:00
7 changed files with 163 additions and 20 deletions

View file

@ -158,7 +158,7 @@ VALUE rb_mod_included_modules(VALUE mod);
VALUE rb_mod_include_p(VALUE child, VALUE parent);
/**
* Queries the module's ancestors. This routine gathers classes and modules
* Queries the module's ancestors. This routine gathers classes and modules
* that the passed module either inherits, includes, or prepends, then
* recursively applies that routine again and again to the collected entries
* until the list doesn't grow up.
@ -187,6 +187,19 @@ VALUE rb_mod_ancestors(VALUE mod);
*/
VALUE rb_class_descendants(VALUE klass);
/**
* Queries the class's direct descendants. This routine gathers classes that are
* direct subclasses of the given class,
* returning an array of classes that have the given class as a superclass.
* The returned array does not include singleton classes.
*
* @param[in] klass A class.
* @return An array of classes where `klass` is the `superclass`.
*
* @internal
*/
VALUE rb_class_subclasses(VALUE klass);
/**
* Generates an array of symbols, which are the list of method names defined in
* the passed class.