A
Ara.T.Howard
i just made a mod to my attributes module which allows this
jib:~/eg/ruby/attributes/attributes-1.1.1 > cat a.rb
require './lib/attributes-1.1.1'
class A
class_attributes %w( x y z )
x 4
y 1
z 1
end
class B < A
y 2
end
class C < B
z 2
end
p A::x
p A::y
p A::z
p B::x
p B::y
p B::z
p C::x
p C::y
p C::z
jib:~/eg/ruby/attributes/attributes-1.1.1 > ruby a.rb
4
1
1
4
2
1
4
2
2
so, as you can see these class attributes are 'inherited' instance values.
this is done using class instance vars and a search up the ancestors list if an
attribute has not been set (defined?) in a class.
questions :
- does this sit o.k. with people : does it violate pols? i think it's quite
natural but that's me ;-)
- what do i call it? for now i'm calling it an class 'inherited' variable
since it's not really a class instance (@) var nor a hierarchy (@@) var.
comments?
-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| renunciation is not getting rid of the things of this world, but accepting
| that they pass away. --aitken roshi
===============================================================================
jib:~/eg/ruby/attributes/attributes-1.1.1 > cat a.rb
require './lib/attributes-1.1.1'
class A
class_attributes %w( x y z )
x 4
y 1
z 1
end
class B < A
y 2
end
class C < B
z 2
end
p A::x
p A::y
p A::z
p B::x
p B::y
p B::z
p C::x
p C::y
p C::z
jib:~/eg/ruby/attributes/attributes-1.1.1 > ruby a.rb
4
1
1
4
2
1
4
2
2
so, as you can see these class attributes are 'inherited' instance values.
this is done using class instance vars and a search up the ancestors list if an
attribute has not been set (defined?) in a class.
questions :
- does this sit o.k. with people : does it violate pols? i think it's quite
natural but that's me ;-)
- what do i call it? for now i'm calling it an class 'inherited' variable
since it's not really a class instance (@) var nor a hierarchy (@@) var.
comments?
-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| renunciation is not getting rid of the things of this world, but accepting
| that they pass away. --aitken roshi
===============================================================================