# Invisible methods and inheritance

**URL:** <https://www.ruby-forum.com/t/invisible-methods-and-inheritance/91988>\
**Category:** Ruby\
**Created:** [April 14, 2007, 12:43am UTC](https://www.ruby-forum.com/t/invisible-methods-and-inheritance/91988 "2007-04-14T00:43:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leslieviljoen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3d9bf3/32.png) [@leslieviljoen](https://www.ruby-forum.com/u/leslieviljoen)\
**Post date:** [April 14, 2007, 12:43am UTC](https://www.ruby-forum.com/t/invisible-methods-and-inheritance/91988/1 "2007-04-14T00:43:32Z")

</div>

Hello!

Does anyone know the reason for the following?

p rio(’.’).all.dirs.methods.include?(“each”)  
p rio(’.’).all.dirs.methods.respond\_to?(“each”)

> false  
> true

I can call dirs.each, but I am trying to trace which .each method is  
called in the rio source. Also how can I find the parent/superclass  
class of a class? (ie. something like Array.parent?)

Les

---

<div class="post-metadata">

**Author:** ![leslieviljoen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3d9bf3/32.png) [@leslieviljoen](https://www.ruby-forum.com/u/leslieviljoen)\
**Post date:** [April 14, 2007, 12:50am UTC](https://www.ruby-forum.com/t/invisible-methods-and-inheritance/91988/2 "2007-04-14T00:50:33Z")

</div>

On Apr 13, 2007, at 15:42 , Leslie V. wrote:

> Hello!
> 
> Does anyone know the reason for the following?
> 
> p rio(’.’).all.dirs.methods.include?(“each”)  
> p rio(’.’).all.dirs.methods.respond\_to?(“each”)
> 
> > false  
> > true

I think you meant:

p rio(’.’).all.dirs.respond\_to?(“each”)

you don’t want to ask the result of methods if IT responds to each,  
you want to ask the result of dirs.

> I can call dirs.each, but I am trying to trace which .each method is  
> called in the rio source.

Don’t forget that things like method\_missing (and even respond\_to?)  
can be overridden.

> Also how can I find the parent/superclass  
> class of a class? (ie. something like Array.parent?)

> > Array.superclass  
> > =\> Object

Remember, ri is your friend, just ask it what you asked us and you’ll  
often find your answer:

## % ri superclass ------------------------------------------------------- Class#superclass class.superclass -\> a\_super\_class or nil

```
  Returns the superclass of _class_, or +nil+.

     File.superclass #=> IO
     IO.superclass #=> Object
     Object.superclass #=> nil
```

---

<div class="post-metadata">

**Author:** ![leslieviljoen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/3d9bf3/32.png) [@leslieviljoen](https://www.ruby-forum.com/u/leslieviljoen)\
**Post date:** [April 14, 2007, 1:32am UTC](https://www.ruby-forum.com/t/invisible-methods-and-inheritance/91988/3 "2007-04-14T01:32:36Z")

</div>

On 4/14/07, Ryan D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > false  
> > > called in the rio source.  
> > > Remember, ri is your friend, just ask it what you asked us and you’ll  
> > > Object.superclass #=\> nil

Thanks Ryan. It seems I am much more tired than I thought I was 😉
