[holy ruby programmers batman!] Stupid string tricks

Giles Bowkett gilesb at gmail.com
Tue Dec 18 19:54:39 EST 2007


Wait. Maybe.

On 12/18/07, Giles Bowkett <gilesb at gmail.com> wrote:
> muahahahahaha!
>
> <mrburns>exxxxxcellent</mrburns>
>
> That's like half the journey to a Ruby shell right there.
>
> On 12/18/07, Avdi Grimm <avdi at avdi.org> wrote:
> > I just added this to my .irbrc:
> >
> > # Add the unix-style pipe command to strings
> > class String
> >   def |(cmd)
> >     IO.popen(cmd, 'r+') do |pipe|
> >       pipe.write(self)
> >       pipe.close_write
> >       pipe.read
> >     end
> >   end
> > end
> >
> > Usage:
> >
> >     "foo\nbar\nbaz" | 'sort' # => "bar\nbaz\nfoo"
> >
> > Feel free to nab it for Utility Belt if you think others might find it useful.
> >
> > --
> > Avdi
> > _______________________________________________
> > Utilitybelt-tinkering mailing list
> > Utilitybelt-tinkering at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/utilitybelt-tinkering
> >
>
>
> --
> Giles Bowkett
>
> Podcast: http://hollywoodgrit.blogspot.com
> Blog: http://gilesbowkett.blogspot.com
> Portfolio: http://www.gilesgoatboy.org
> Tumblelog: http://giles.tumblr.com
>


-- 
Giles Bowkett

Podcast: http://hollywoodgrit.blogspot.com
Blog: http://gilesbowkett.blogspot.com
Portfolio: http://www.gilesgoatboy.org
Tumblelog: http://giles.tumblr.com


More information about the Utilitybelt-tinkering mailing list