From: leon breedt Date: 2005-01-19T11:29:30+09:00 Subject: Re: [ANN] Rails 0.9.4: Caching, filters, SQLite3… On Mon, 17 Jan 2005 11:23:26 +0900, David Heinemeier Hansson wrote: > * *Numeric bytes and time:* Rails has taken upon itself to extend Ruby > in a few spots, such as adding the possibility for expressions like > 45.kilobytes + 2.3.megabytes and 45.minutes + > 2.hours + 1.fortnight. What do you think of adding: def octet_units(fmt='%.2f') case when self < 1.kilobyte "#{self} bytes" when self < 1.megabyte "#{fmt % (self.to_f / 1.kilobyte)} KB" when self < 1.gigabyte "#{fmt % (self.to_f / 1.megabyte)} MB" when self < 1.terabyte "#{fmt % (self.to_f / 1.gigabyte)} GB" else "#{fmt % (self.to_f / 1.terabyte)} TB" end end to the Numeric helpers? Leon