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

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top