lib/halog/utils.rb
def num_to_bytes(num,fmt="%.2f")
    case
    when num < 1024
        "#{num} bytes"
    when num < 1024**2
        "#{fmt % (num.to_f / 1024)} KB"
    when num < 1024**3
        "#{fmt % (num.to_f / 1024**2)} MB"
    when num < 1024**4
        "#{fmt % (num.to_f / 1024**3)} GB"
    when num < 1024**5
        "#{fmt % (num.to_f / 1024**4)} TB"
    else
        "#{num} bytes"
    end
  end
# essentially this is strfbytes from facets
essentially this is strfbytes from facets
essentially this is strfbytes from facets
def num_to_bytes(num,fmt="%.2f")
    case
    when num < 1024
        "#{num} bytes"
    when num < 1024**2
        "#{fmt % (num.to_f / 1024)} KB"
    when num < 1024**3
        "#{fmt % (num.to_f / 1024**2)} MB"
    when num < 1024**4
        "#{fmt % (num.to_f / 1024**3)} GB"
    when num < 1024**5
        "#{fmt % (num.to_f / 1024**4)} TB"
    else
        "#{num} bytes"
    end
  end
def num_to_bytes ( num , fmt = "%.2f" ) case when num < 1024 "#{num} bytes" when num < 1024 ** 2 "#{fmt % (num.to_f / 1024)} KB" when num < 1024 ** 3 "#{fmt % (num.to_f / 1024**2)} MB" when num < 1024 ** 4 "#{fmt % (num.to_f / 1024**3)} GB" when num < 1024 ** 5 "#{fmt % (num.to_f / 1024**4)} TB" else "#{num} bytes" end end
essentially this is strfbytes from facets
essentially this is strfbytes from facets
num
fmt