I want to create a class that has one method that calls all other methods that are not in the super class.
Is there a way I can use obj.methods to only get the non-ancestral methods? Or is there another way to do it entirely.
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m not sure what you’re really trying to do here, nor which methods you mean by ‘all’, but if the question is how you figure out which of a class’s instance methods aren’t inherited, the combination of .instance_methods and .ancestors can get you that info. Here, using Array as an example class:
If you literally only want to rule out methods from the superclass, as opposed to the included ones, there’s also .superclass.
Does that help?