From: Bill Atkins Date: 2005-01-05T00:23:27+09:00 Subject: Re: Composition or Module Module seems more natural to me, but maybe "Representable" would be a better name. On Tue, 4 Jan 2005 23:33:10 +0900, Tomoyuki Kosimizu wrote: > Hi, > > Let me hear your opinions, composition or module. > > Composition: > > class Representation > def to_string(obj) > return sprintf('%s=%s', obj.class, obj.value) > end > end > > class Domain > def initialize > @value = 10 > end > attr_reader :value > > def to_s > Representation.new.to_string(self) > end > end > > puts(Domain.new) > > or Module: > > module Representation > def to_s > return sprintf('%s=%s', self.class, @value) > end > end > > class Domain > include Representation > > def initialize > @value = 10 > end > end > > puts(Domain.new) > > greentea@fa2.so-net.ne.jp > > -- $stdout.sync = true "Just another Ruby hacker.".each_byte do |b| ('a'..'z').step do|c|print c+"\b";sleep 0.007 end;print b.chr end; print "\n"