From: Tim Pease Date: 2006-06-28T05:10:43+09:00 Subject: Re: Define External Superclass in a extension This has worked for me in the past ... VALUE tmp, your_class; rb_require( "dbi" ); tmp = rb_const_get( rb_cObject, rb_intern("DBI") ); tmp = rb_const_get( tmp, rb_intern("BaseDriver") ); your_class = rb_define_class( "YourClass", tmp ); The rb_require used above will not work for gems. You'll have to call the require method of the Gem module to load gems. Blessings, Tim Pease On 6/27/06, Ceaser Larry wrote: > I'm trying to learn how to create a ruby extension. I've read the > pick axe book but I'm running into a problem understanding how to get > a reference to classes defined outside the ruby.h header. > > My problem is how do I reference the DBI::BaseDriver as a super class > to my object? > > In C I understand I can use the following to define a new class > > VALUE rb_cMyClass = rb_define_class("MyClass", rb_cObject) > > somehow I need to replace rb_cObject with a reference to the > DBI::BaseDriver like so > > VALUE rb_cMyClass = rb_define_class("MyClass", [DBI::BaseDriver]) > > Any help or nudge in the right direction would be appreciated. > > Thanks > Ceaser > >