confusion with extension modules

G

goldfita

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top