From: Leonardo Francalanci Date: 2005-04-21T23:42:18+09:00 Subject: Re: accessor for Class Variable > AFAIK there is not, I think you're supposed to access a class variable > directly from instances and class methods, and to generally use a > constant when possible, wich is visible from outside. > In general the use case for class attributes accessible from the outside > is not that much (in my own experience). Ok, got it, I changed them into constants. > Anyway you should be able to write them easily with something like > (untested): > > class Class > def class_attr sym > module_eval "def self.#{sym}() @@#{sym} end" > module_eval "def self.#{sym}=(x) @@#{sym}=x end" > end > end > > class C > class_attr :foo > end Wow, looks like I have to learn a lot of stuff...