From: Intransition Date: 2009-12-20T05:58:27+09:00 Subject: Re: Encapsulating Information and Behavior without State On Dec 19, 10:58 am, Robert Klemme wrote: > What's wrong with doing > >    class UnitType >      class<        attr_accessor :power >      end > >      # ... methods ... > >      def self.i_ve_got_the_power >        puts "#{self}'s power is #{power}" >      end >    end > >    class Meter < UnitType >      self.power = 123 >      # ... override methods ... >    end > >    class Second < UnitType >      self.power = 456 >      # ... override methods ... >    end > > irb(main):022:0> Meter.i_ve_got_the_power > Meter's power is 123 > => nil > irb(main):023:0* Second.i_ve_got_the_power > Second's power is 456 > => nil > Nothing. Indeed I think that is the way to do it (if the static-class approach is taken). singleton.rb is again proven rather toothless. thanks.