# Class Methods

**URL:** <https://www.ruby-forum.com/t/class-methods/94591>\
**Category:** Ruby\
**Created:** [May 8, 2006, 2:55pm UTC](https://www.ruby-forum.com/t/class-methods/94591 "2006-05-08T14:55:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgreenly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@mgreenly](https://www.ruby-forum.com/u/mgreenly)\
**Post date:** [May 8, 2006, 2:55pm UTC](https://www.ruby-forum.com/t/class-methods/94591/1 "2006-05-08T14:55:02Z")

</div>

Here’s some simple code:

def ClassA  
def my\_method

end  
end

def ClassB \< ClassA  
def my\_new\_method

end  
end

* * *

What is the best way to get a list of instance methods for ClassB, but  
that  
does not contain the parent class’s methods?

ClassB.instance\_methods is returning all of them. I just want to see  
‘my\_new\_method’.

Any ideas?

---

<div class="post-metadata">

**Author:** ![mgreenly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@mgreenly](https://www.ruby-forum.com/u/mgreenly)\
**Post date:** [May 8, 2006, 3:01pm UTC](https://www.ruby-forum.com/t/class-methods/94591/2 "2006-05-08T15:01:55Z")

</div>

Michael G. wrote:

> What is the best way to get a list of instance methods for ClassB, but  
> that  
> does not contain the parent class’s methods?
> 
> ClassB.instance\_methods is returning all of them. I just want to see  
> ‘my\_new\_method’.

ClassB.instance\_methods - ClassB.superclass.instance\_methods

---

<div class="post-metadata">

**Author:** ![mgreenly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@mgreenly](https://www.ruby-forum.com/u/mgreenly)\
**Post date:** [May 8, 2006, 3:10pm UTC](https://www.ruby-forum.com/t/class-methods/94591/3 "2006-05-08T15:10:34Z")

</div>

> > > > > “M” == Michael G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

M\> ClassB.instance\_methods is returning all of them. I just want to see  
M\> ‘my\_new\_method’.

ClassB.instance\_methods(false)

Guy Decoux
