From: Eero Saynatkari Date: 2006-10-24T12:38:39+09:00 Subject: Re: Override Time#to_s -- how? --Q3iZjccpNGsIEgQL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 2006.10.24 10:48, Wilson Bilkovich wrote: > On 10/23/06, Ben Winekur wrote: > >Hey everyone, > > > >I'd like to override the Time#to_s function to parse Time objects a > >specific way -- how can I do this from within my script? (Without > >modifying the Time class itself) > > > class Time > alias_method :original_to_s, :to_s > def to_s > "The old to_s method would have said: " + self.original_to_s > end > end Time#to_s is one of the core methods I have absolutely no qualms overriding but if you would rather not, there is always #strftime. ri Time#strftime --Q3iZjccpNGsIEgQL Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (FreeBSD) iD8DBQFFPYoq7Nh7RM4TrhIRAu3kAJoCtsgR52ZsnGLDeTg1d8QG2yHsmQCdFjPz zBL1QzoV9MbbDXAALPYPOVI= =I02C -----END PGP SIGNATURE----- --Q3iZjccpNGsIEgQL--