From: Greg Hauptmann Date: 2008-08-06T14:50:48+09:00 Subject: Re: is there a way to AutoParse a string to another type - e.g. if a Date format then date, else if integer than Integer etc ????? ------=_Part_13622_22546450.1218001945234 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline umm...Date parse doesn't seem to be that good, for example see below >> Loading development environment (Rails 2.1.0) >> ?> Date.parse("123", "%d/%m/%Y") => Fri, 02 May 2008 >> Date.parse("123", "%d/%m/%Y").class => Date >> On 8/6/08, Greg Hauptmann wrote: > > thanks - in one line too....so I could do in fact then I guess: > > value = Date.parse(string) rescue Integer(string) rescue Float(string) > rescue string > > > > > On 8/6/08, ara.t.howard wrote: > > > > > > On Aug 5, 2008, at 10:53 PM, Greg Hauptmann wrote: > > > > Does this exist somewhere in Ruby already? Or do I have to write myself? > >> > > > > > > require 'date' > > > > value = Date.parse(string) rescue Integer(string) > > > > > > > > > > a @ http://codeforpeople.com/ > > -- > > we can deny everything, except that we have the possibility of being > > better. simply reflect on that. > > h.h. the 14th dalai lama > > > > > > > > > > > ------=_Part_13622_22546450.1218001945234--