From: Mark Somerville Date: 2007-03-13T20:44:30+09:00 Subject: Re: BigDecimal bug? On Tue, Mar 13, 2007 at 08:08:07PM +0900, Mark Somerville wrote: > I have tried altering the BigDecimal initialisation code, without success. > Does anyone have any clues as to how to workaround this issue without > pre-processing the "-.31" string? I'd think I could alter the "new" call to > alter the malformed string a little. I've managed to get a workaround going now (I realise this is a poor substitute for fixing the poorly formed decimals), but I don't understand why I need to wrap the alias_method inside class << self. Can anyone explain it to me? class BigDecimal #why do I need to wrap this in class << self ??? class << self alias_method 'original_new', 'new' end def self.new(value) value = "-0.#{$1}" if value =~ /^-\.(.+)$/ return original_new(value) end end Cheers, Mark