Hi all,
I want to create a module with some constants that can then be accessed as Class
methods.
e.g.
#/usr/bin/ruby
require 'test'
puts Test.Test_constant
Where 'Test_constant' is a readable constant.
The .c file I think would look something like:
#include "ruby.h"
void Init_test()
{
tClass = rb_define_class("Test",rb_cObject);
tString = rb_str_new2("Hello");
rb_define_const(tClass,"Test_constant",tString);
rb_cv_set(tClass,"@@Test_constant",tString);
rb_define_attr(tClass,"Test_constant",1,0);
}
But this doesn't work. I'm sure this is easy - I'm clearly foggy today.
Thanks in advance for any help.
Regards,
Dan