[Nitro] Again me...

TRANS transfire at gmail.com
Tue Sep 6 00:16:21 EDT 2005

On 9/5/05, Emmanuel Piperakis <epiperak at softlab.ece.ntua.gr> wrote:
> Sorry for all the bothering...
> I would like to store in the DB an object of type Currency that I made.
> (Just a Float will not do, I need to convert from JPY, to USD, EUR, and so
> on, but also store the different type of number each time - once
> representing JPY with no decimal digits, the other time USD with 2
> decimal, etc etc). So I did the followin in the model.rb
> class Currency < Float
>    def initialize(value = 0.0, type = 'JPY', precission = 0)
>      super
>      @value, @type, @precission = value, type, precission
>    end
>    def jpy
>    end
>    def usd
>    end
>    def eur
>    end
> end

In some cases Ruby does not make subclassing feasible, like with
Float. So subclassing Float will do you no good. You are simply
delegating via the three instance vars. Get rid of  < Float and the
call to super.

Not sure what Nitro's doing though.


More information about the Nitro-general mailing list