From: Yossef Mendelssohn Date: 2012-01-15T16:31:17+09:00 Subject: Re: Help or Advice appreciated for parsing On Jan 14, 9:09 pm, Marc Heiler wrote: > So I then thought "Let's try this:" > >   area.shape 'rext' .coords '1,1,100,50' .href 'http://www.foobar.com' > > Ok, this does not work in Ruby. Even adding () won't work, the method > chaining happens on String object eventually (and I would have cheated, > area would be def area, so area() instead, returning a specific class > that would respond to methods like shape, coords, href. There's no reason that with appropriate parens wouldn't work. By appropriate parens I mean area.shape('rect').coords('1,1,100,50').href('http:// www.foobar.com') Look into Fluent Interfaces for more info on that sort of thing. This easily gets into contentious areas like metaprogramming, blank objects, DSLs, and creating new languages (or dialects). Consider how much you really want this. Look into already existing projects that are already in this arena, like, say, HAML. > I am not really sure if I am able to express what I am trying to > achieve. :) Well, that's something to work on. Good luck. -- -yossef