From: Daniel Carrera Date: 2003-01-25T07:59:35+09:00 Subject: Ruby Modules in C I'm struggling to write a module, with a method, in C. With plain Ruby, I would do something like this: >> module M >> def M.five >> return 5 >> end >> end => nil >> M.five => 5 So I thought that, in C, I could write: #include "science.h" static VALUE mScience_seven(VALUE self) { return rb_float_new(7); } VALUE mScience; void Init_science() { /* Module definition */ mScience = rb_define_module("Science"); mScience_define_constants(); rb_define_method(mScience, "Science.seven", mScience_seven, 0); } The module itself builds, and I can access the constants fine. But the method is giving me trouble: >> require 'science' => true >> Science::SOLAR_MASS => 1.98892e+30 >> Science.seven NameError: undefined method `seven' for Science:Module from (irb):3 >> I've also tried rb_define_method(..."seven"...), but that didn't work either. Does anyone know how I can write module methods in C? Thanks. -- Daniel Carrera Graduate Teaching Assistant. Math Dept. University of Maryland. (301) 405-5137