From: Glenn Jackman Date: 2009-12-04T02:05:19+09:00 Subject: Re: easy dsl style method generation? At 2009-12-03 10:38AM, "Roger Pack" wrote: > Here's what I wish I could easily do. > > Move.from(x).to(y) > > and set it up easily, like > > class Move > def from(x).to(y) > > end > end > > Any helpers out there to make this somewhat possible that anyone knows > of? My spidey-sense tells me you're trying to do something like this: class Move def move(from, to) if @location == from @location = to else raise "I'm not located at #{from}!" end end end m.move(x, y) Multi-word methods can be found in Smalltalk, but not in Ruby. Another possibility that makes calling your method more readable: class Move def move(coords) if @location == coords[:from] @location = coords[:to] else raise "I'm not located at #{coords[:from]}!" end end end m.move(:from => x, :to => y) -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous