# Strange ruby documentation ?!

**URL:** <https://www.ruby-forum.com/t/strange-ruby-documentation/155323>\
**Category:** Ruby\
**Created:** [December 10, 2008, 4:04pm UTC](https://www.ruby-forum.com/t/strange-ruby-documentation/155323 "2008-12-10T16:04:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chucky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b782af/32.png) [@chucky](https://www.ruby-forum.com/u/chucky)\
**Post date:** [December 10, 2008, 4:04pm UTC](https://www.ruby-forum.com/t/strange-ruby-documentation/155323/1 "2008-12-10T16:04:30Z")

</div>

Hi,

I noticed soon something weird about Object documentation (in fact, one  
of my colleagues saw it and he asked me what’s the catch):

- Object class ([class Object - RDoc Documentation](http://www.ruby-doc.org/core/classes/Object.html)) have  
one method called to\_yaml. Now, the funny thing is that when trying to  
do that:

irb(main):001:0\> a = “abc”  
=\> “abc”  
irb(main):002:0\> a.to\_yaml  
NoMethodError: undefined method `to\_yaml’ for “abc”:String  
from (irb):2  
from :0

but after require ‘yaml’ everything is ok.

Ok, I know that yaml is placing this method to Object class when  
required, but why is it by default documented in Object class ? What may  
be the reason ?

Thanks.

---

<div class="post-metadata">

**Author:** ![chucky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b782af/32.png) [@chucky](https://www.ruby-forum.com/u/chucky)\
**Post date:** [December 10, 2008, 6:32pm UTC](https://www.ruby-forum.com/t/strange-ruby-documentation/155323/2 "2008-12-10T18:32:05Z")

</div>

Alin P. wrote:

> Ok, I know that yaml is placing this method to Object class when  
> required, but why is it by default documented in Object class ? What may  
> be the reason ?

It’s the way rdoc currently works; it parses a set of files and rolls up  
methods found for the various classes and modules it encounters. It is  
not able to indicate from where a method originated or that certain  
methods are provided on an object only when one or another module is  
included.

–  
James B.

[www.happycamperstudios.com](http://www.happycamperstudios.com) - Wicked Cool Coding  
[www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys  
[www.ruby-doc.org](http://www.ruby-doc.org) - Ruby Help & Documentation  
[www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff

---

<div class="post-metadata">

**Author:** ![chucky](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/b782af/32.png) [@chucky](https://www.ruby-forum.com/u/chucky)\
**Post date:** [December 10, 2008, 6:42pm UTC](https://www.ruby-forum.com/t/strange-ruby-documentation/155323/3 "2008-12-10T18:42:48Z")

</div>

James B. wrote:

> Alin P. wrote:
> 
> > Ok, I know that yaml is placing this method to Object class when  
> > required, but why is it by default documented in Object class ? What may  
> > be the reason ?
> 
> It’s the way rdoc currently works; it parses a set of files and rolls up  
> methods found for the various classes and modules it encounters. It is  
> not able to indicate from where a method originated or that certain  
> methods are provided on an object only when one or another module is  
> included.
> 
> –  
> James B.
> 
> [www.happycamperstudios.com](http://www.happycamperstudios.com) - Wicked Cool Coding  
> [www.jamesbritt.com](http://www.jamesbritt.com) - Playing with Better Toys  
> [www.ruby-doc.org](http://www.ruby-doc.org) - Ruby Help & Documentation  
> [www.rubystuff.com](http://www.rubystuff.com) - The Ruby Store for Ruby Stuff

Thanks James,

It makes sense.
