class Float

Public Instance Methods

to_human_size() click to toggle source
# File lib/collins_shell/monkeypatch.rb, line 6
def to_human_size
  return "0 Bytes" if (self == 0)
  i = (Math.log(self) / Math.log(1024)).floor.to_i
  small = self / (1024 ** i)
  if i == 0 then
    "#{self} #{SIZE_ARRAY[i]}"
  else
    sprintf("%.14f %s", small, SIZE_ARRAY[i])
  end
end