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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 122k
  • Answers 122k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Take a look at Python Eggs: http://peak.telecommunity.com/DevCenter/PythonEggs Or, you can… May 12, 2026 at 12:36 am
  • Editorial Team
    Editorial Team added an answer I agree that this is subjective. For the most part… May 12, 2026 at 12:36 am
  • Editorial Team
    Editorial Team added an answer You'd just use a pair of iterators: typedef std::vector<int>::iterator vec_iter;… May 12, 2026 at 12:36 am

Related Questions

I'm developping a small UML Class editor in Java, mainly a personal project, it
UPDATED I've updated the example to better illustrate my problem. I realised it was
I have a web-app-database 3 tier server setup. Web requests data from app, and
I'm aiming to create a set of objects, each of which has a unique

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.