Robert Klemme <bob.news / gmx.net> wrote:
> "Martin DeMello" <martindemello / yahoo.com> schrieb im Newsbeitrag
> news:0JEvc.620827$Pk3.157220 / pd7tw1no...
> > I'm writing a small wrapper around ruby, meant to be used as part of a
> > unix pipeline filter - e.g.
> >
> >  ls -l | rbx 'cols(8,4).mapf(:to_s).formatrow(" ", 30, 8).endl'
> 
> I'd perfer to have something in front of cols() that does the splitting -
> otherwise it's always space separated which might limit usefulness.

Hm - I was trying to avoid an extraneous 'split', since cols always
requires one. Maybe check if the first argument is a string and split on
that, otherwise split on space.

> >
> > class Array
> >   def take_while!
> 
> This name is misleading since it suggests that array is manipulated in
> place.  Better remove the "!".

It is - I'm using 'shift'. I figured optionparse was overkill since I
just wanted to pass the options along to ruby.

> Why do you spawn an extra process here?  IMHO that's superfluous.  If you
> put the command into a block, your main loop will look like this:

Mostly because it started life as a shellscript, and then migrated over
when I coldn't figure out how to do option parsing properly :)

> while ( line = gets )
>   line.chomp!
>   command.call line
> end
> 
> To do that you just need
> 
> command = eval %Q{ lambda {|line| puts line.instance_eval(
> '#{ARGV.shift}' ) } }

But how will that let us pass options to the ruby interpreter?

martin