From: Tiago Pinto Date: 2007-02-03T03:32:16+09:00 Subject: Re: halving a string Hi Chris, > I have a vacuum fluorescent display in my office, and I've been > messing around with it. Now that I've figured out how to communicate > with the serial connection it's time for some fun. aside the string hackery, will the comunication be done using ruby? ;P On 2/2/07, Trans wrote: > > > On Feb 2, 10:55 am, Rob Biedenharn > wrote: > > On Feb 1, 2007, at 11:10 PM, Chris Shea wrote: > > > Good solutions already, but I had to chime in with one less clever > > and without regexps. > > I also didn't like "halve" as a name so I used "cleave". > > > > Enjoy! > > > > class String > > def cleave > > middle = self.length/2 > > early = self.rindex(' ', middle) > > late = self.index(' ', middle) > > [snip] > > This is nice and versitle. One good augmentation might be... > > def cleave(middle=nil) > middle ||= self.length/2 > > T. > > > -- Tiago Pinto Developer, Event Coordinator - Webreakstuff Email: tpinto@webreakstuff.com http://webreakstuff.com