Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 164067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:40:42+00:00 2026-05-11T11:40:42+00:00

I want to create a class that has one method that calls all other

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T11:40:43+00:00Added an answer on May 11, 2026 at 11:40 am

    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:

    Array.instance_methods.sort                                                                          => ['&', '*', '+', '-', '<<', '<=>', '==', '===', '=~', '[]', '[]=', '__id__', '__send__', 'all?', 'any?', 'assoc', 'at', 'class', 'clear', 'clone', 'collect', 'collect!', 'compact', 'compact!', 'concat', 'delete', 'delete_at', 'delete_if', 'detect', 'display', 'dup', 'each', 'each_index', 'each_with_index', 'empty?', 'entries', 'eql?', 'equal?', 'extend', 'fetch', 'fill', 'find', 'find_all', 'first', 'flatten', 'flatten!', 'freeze', 'frozen?', 'grep', 'hash', 'id', 'include?', 'index', 'indexes', 'indices', 'inject', 'insert', 'inspect', 'instance_eval', 'instance_of?', 'instance_variable_get', 'instance_variable_set', 'instance_variables', 'is_a?', 'join', 'kind_of?', 'last', 'length', 'map', 'map!', 'max', 'member?', 'method', 'methods', 'min', 'nil?', 'nitems', 'object_id', 'pack', 'partition', 'pop', 'private_methods', 'protected_methods', 'public_methods', 'push', 'rassoc', 'reject', 'reject!', 'replace', 'respond_to?', 'reverse', 'reverse!', 'reverse_each', 'rindex', 'select', 'send', 'shift', 'singleton_methods', 'size', 'slice', 'slice!', 'sort', 'sort!', 'sort_by', 'taint', 'tainted?', 'to_a', 'to_ary', 'to_s', 'transpose', 'type', 'uniq', 'uniq!', 'unshift', 'untaint', 'values_at', 'zip', '|']  Array.ancestors => [Array, Enumerable, Object, Kernel]  Array.instance_methods.sort - Array.ancestors.map {|a| a == Array ? [] : a.instance_methods}.flatten => ['&', '*', '+', '-', '<<', '<=>', '[]', '[]=', 'assoc', 'at', 'clear', 'collect!', 'compact', 'compact!', 'concat', 'delete', 'delete_at', 'delete_if', 'each', 'each_index', 'empty?', 'fetch', 'fill', 'first', 'flatten', 'flatten!', 'index', 'indexes', 'indices', 'insert', 'join', 'last', 'length', 'map!', 'nitems', 'pack', 'pop', 'push', 'rassoc', 'reject!', 'replace', 'reverse', 'reverse!', 'reverse_each', 'rindex', 'shift', 'size', 'slice', 'slice!', 'sort!', 'to_ary', 'transpose', 'uniq', 'uniq!', 'unshift', 'values_at', '|'] 

    If you literally only want to rule out methods from the superclass, as opposed to the included ones, there’s also .superclass.

    Array.superclass => Object  Array.instance_methods.sort - Array.superclass.instance_methods => ['&', '*', '+', '-', '<<', '<=>', '[]', '[]=', 'all?', 'any?', 'assoc', 'at', 'clear', 'collect', 'collect!', 'compact', 'compact!', 'concat', 'delete', 'delete_at', 'delete_if', 'detect', 'each', 'each_index', 'each_with_index', 'empty?', 'entries', 'fetch', 'fill', 'find', 'find_all', 'first', 'flatten', 'flatten!', 'grep', 'include?', 'index', 'indexes', 'indices', 'inject', 'insert', 'join', 'last', 'length', 'map', 'map!', 'max', 'member?', 'min', 'nitems', 'pack', 'partition', 'pop', 'push', 'rassoc', 'reject', 'reject!', 'replace', 'reverse', 'reverse!', 'reverse_each', 'rindex', 'select', 'shift', 'size', 'slice', 'slice!', 'sort', 'sort!', 'sort_by', 'to_ary', 'transpose', 'uniq', 'uniq!', 'unshift', 'values_at', 'zip', '|'] 

    Does that help?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a wrapper class so that all queries should not be
I want to create a Javascript class/object that allow me to have various method:
I want to create a substr method in C++ in a string class that
I have a class that extends RemoteServiceServlet. This class has several methods, in one
I'm trying to create a simple class THistory that has one procedure that takes
I want to create a class that initializes a timer which will be used
I want to create whois class like that public class DomainInfo { public string
If I create a class that extends UserControl and want to set a default
I have a signed class library that I want to create assemblies for via
I want to create a template class (let's call it Foo ) that only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.