1
0
mirror of https://github.com/cmur2/openvpn-status-web.git synced 2025-08-07 22:33:57 +02:00

Convert into gem

This commit is contained in:
cn
2013-05-03 15:32:08 +02:00
parent 2f2160b985
commit 283c05d9d3
15 changed files with 208 additions and 77 deletions

View File

@@ -0,0 +1,16 @@
class Integer
def as_bytes
return "1 Byte" if self == 1
label = ["Bytes", "KiB", "MiB", "GiB", "TiB"]
i = 0
num = self.to_f
while num >= 1024 do
num = num / 1024
i += 1
end
"#{format('%.2f', num)} #{label[i]}"
end
end