Forum: Ruby confusion with extension modules

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6c268a2652724ef54586b9ff88f414f4?d=identicon&s=25 unknown (Guest)
on 2005-12-31 12:51
(Received via mailing list)
Hi,

I'm trying to write a very simple extension module using the example -
http://www.rubycentral.com/book/ext_ruby.html

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?

thanks!
6c268a2652724ef54586b9ff88f414f4?d=identicon&s=25 unknown (Guest)
on 2006-01-01 21: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.