On Mon, Dec 2, 2013 at 4:40 PM, Jes=FAs Gabriel y Gal=E1n
<jgabrielygalan / gmail.com> wrote:
> I'm not so sure about ARGF, it seems to be a special thing:
>
> 2.0.0-p195 :011 > ARGF.class
>  =3D> ARGF.class
> 2.0.0-p195 :010 > ARGF.superclass
> NoMethodError: undefined method `superclass' for ARGF:ARGF.class
>
> I guess I'll have to read a bit more about it.

Just for my own education: ARGF is an object of a class that is
defined inside io.c (MRI). That class is named ARGF.class

    rb_cARGF =3D rb_class_new(rb_cObject);
    rb_set_class_path(rb_cARGF, rb_cObject, "ARGF.class");

The first line creates an anonymous class that inherits from Object.
The second line is a bit magical for me, but based on my tests it
seems to tell Ruby that the class name is "ARGF.class":

2.0.0-p195 :003 > ARGF.send :class
 =3D> ARGF.class

It includes Enumerable:

2.0.0-p195 :006 > ARGF.class.ancestors
 =3D> [ARGF.class, Enumerable, Object, Kernel, BasicObject]

So, summary: ARGF is an object of class ARGF.class. As to why this is
implemented in such way instead of a regular class, I don't know, but
there's a hack in the code to make rdoc treat the object itself as a
class:

#if 0
    /* Hack to get rdoc to regard ARGF as a class: */
    rb_cARGF =3D rb_define_class("ARGF", rb_cObject);
#endif

This makes it confusing also, since if you check the documentation
you'd think that ARGF is actually a class when it isn't.

Jesus.