From: Peter Ertl Date: 2006-03-24T01:39:27+09:00 Subject: Re: Is this a kind of design patterns? I got great improvements to make color usage enterprise ready... Here comes my first class color object using state-of-the-art design patterns for better scalability and performance I was designed using the rational design process + UML class ColorRegistry private def self.mix(*colors) r,g,b=[0,0,0] while color = colors.shift r += color[0] g += color[1] b += color[2] end [r,g,b] end RED = [255,0,0] GREEN = [0,0b11111111,0] BLUE = [0,0,0xff] WHITE = mix(RED, GREEN, BLUE) YELLOW = mix(RED, GREEN) # more to come public def self.get_binding binding end end class ColorEvaluator def self.get(name) eval(name.upcase, ColorRegistry.get_binding) end end puts ColorEvaluator.get("yellow") puts ColorEvaluator.get("red") puts ColorEvaluator.get("white") > --- Urspr�ngliche Nachricht --- > Von: Jim Weirich > An: ruby-talk@ruby-lang.org (ruby-talk ML) > Betreff: Re: Is this a kind of design patterns? > Datum: Fri, 24 Mar 2006 01:13:52 +0900 > > Robert Klemme wrote: > > Since we're in Color anyway, you can simplify the definition that by > > I like that. > > And I love the collective refactoring that goes on in this list! > > -- > -- Jim Weirich > > -- > Posted via http://www.ruby-forum.com/. >