From: Scott Thompson Date: 2003-08-13T13:03:14+09:00 Subject: Exposing C "enums" through extensions I'm allowing Ruby to access a C based library through an extension. I'd like to expose some of the enums that are in the C interface, but wasn't sure about the best way to do this. My first thought was to define them as class variables within the relevant class. But then, as I discovered, there wasn't a good way I could keep external code from modifying the values of those variables. It would be really bad if someone set the value of the "miter line join" constant to 7 when the only valid range of values is 0 - 3. On the "Extending Ruby" web site at , I found the routine"rb_define_readonly_variable" which sounds pretty good. But, so far as I can tell, it defines a global variable and my preference would be to scope the variables inside of a class (I don't know why... it just seems "tidier"). Is there a common mechanism that is followed in other extensions? Scott