En r?ponse ? Peter Hickman <peter / semantico.com>:

> I have used
> 
> class Test
> 	def Test.Calc(x)
> 		return x * 2
> 	end
> end
> 
> class Fred < Test
> end
> 
> puts Fred.Calc(12)
> 
> which return 24 and is what I expected. But what I wanted to do was
> 
> class Test
> 	def Test.Calc(x)
> 		return @@rate * x
> 	end
> end
> 
> class Fred < Test
> 	@@rate = 10
> end
> 
> puts Fred.Calc(12)
> 
> which
> 
> s2:3:in `Calc': uninitialized class variable @@rate in Test
> (NameError)
> 	from s2:11
> 
> Now the class method has been inherited (and named accordingly) and I 
> was expecting it to use the class variable as defined in Fred but it was
> 
> trying to pick up the class variable in Test. How can I have the 
> inheritence of a class method that accesses the class variable of the 
> child class?
> 
> This is a gross simplification, the class I am designing would really 
> benefit from this working as I hoped. Oh yes. I am using ruby 1.6.7 
> (2002-03-19) [i386-linux]
> 
> Any pointers greatly appreciated.
> 
> 

I'm not sure, but you should put your rate variable in class test and your calc 
method in class fred.
This way may work better.
Because I think it's impossible to access a child member.

Or Unless you define it static.
In other programming language you could write:
fred::rate to access it from anywhere...

So, you have 2 solutions.

Sory, I can't give you a ruby implementation because I'm starting to use it.