Adding a method to String class as Ruby C extension

  • Thread starter Iñaki Baz Castillo
  • Start date
I

Iñaki Baz Castillo

Hi, I want to add a method to String class, and I want this method to
be defined in C.

In the C code, to add a method I must do:

rb_define_method(myClass, "hello", hello, arg_count);

but I don't know how to set myClass to point to String class.


To create a new class I should do:

VALUE myClass =3D rb_define_class_under(myModule, "MyClass", rb_cObject);

Since rb_cObject means Ruby Object class, could be rb_cString what I'm
looking for?

Thanks.


--=20
I=C3=B1aki Baz Castillo
<[email protected]>
 

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

No members online now.

Forum statistics

Threads
473,888
Messages
2,569,964
Members
46,293
Latest member
BonnieHamb

Latest Threads

Top