On 3/14/06, James Edward Gray II <james / grayproductions.net> wrote:> On Mar 14, 2006, at 2:11 AM, Wink Saville wrote:> > I was looking for a routine to convert a Number to a string with> > comma's, is there a routine in the library for that?>> It's not very hard to roll up a solution:>>    def commify( number )>      number.to_s.reverse.gsub(/(\d\d\d)(?=\d)(?!\d*\.)/, '\1,').reverse>    end
...it's significantly harder to do it completely *right*, though.
See Gavin Sinclair's Extensions library in Numeric. I have arelatively complete method written there, done in test-first style.
-austin--Austin Ziegler * halostatue / gmail.com               * Alternate: austin / halostatue.ca