public_instance_methods is a class- or module-level query that returns the public instance methods available to instances. It is a synonym for instance_methods when selecting public methods, rather than protected ones. section 7.7.3 section 15.2.3
Own methods versus inherited methods
Range.public_instance_methods(false) restricts the result to public methods defined directly by Range. Calling Range.public_instance_methods without an argument also includes public methods supplied by ancestor classes and modules. section 15.2.3
Use the method-listing family to inspect different parts of a class or module's instance-method surface:
- instance_methods returns public and protected instance methods. section 15.2.3
- public_instance_methods returns only public instance methods; protected_instance_methods and private_instance_methods select the other visibility levels. section 15.2.3
- Intersect method lists with & to identify methods shared by a class and a module, such as Range and Enumerable. section 15.2.3
String.instance_methods(false).sort
Inspect String's directly defined instance methods and sort the resulting list for a fine-grained view of method placement. section 7.7.3
