Forum: Ruby confusion with extension modules

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2005-12-31 13:51
(Received via mailing list)

I'm trying to write a very simple extension module using the example -

This is my version.  The other methods are defined elsewhere.  This
compiles and loads into irb.

void Init_dumphead()
    dumphead = rb_define_class("head", rb_cObject);
    rb_define_singleton_method(dumphead, "new", dh_new, 0);
    rb_define_method(dumphead, "initialize", dhead_init, 0);

The example refers directly to its version of "head", but when I try to
do this, I get a NameError on head.  I'm also confused about what is
being imported into the environment.  Is dumphead (from Init_dumphead)
a module?  Wouldn't I have to refer to head using dumphead::head?  If
not, how would I make it a module?

unknown (Guest)
on 2006-01-01 22:31
(Received via mailing list)
I got it!  It needs to be Head, not head.
This topic is locked and can not be replied to.