On Mon, 17 Jan 2005 11:23:26 +0900, David Heinemeier Hansson
<david / loudthinking.com> 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
> <code>45.kilobytes + 2.3.megabytes</code> and <code>45.minutes +
> 2.hours + 1.fortnight</code>.
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