class Numeric
Public Instance Methods
GB()
click to toggle source
# File lib/humansiz.rb, line 34 def GB ; self * G ; end
GiB()
click to toggle source
# File lib/humansiz.rb, line 47 def GiB ; self * Gb ; end
MB()
click to toggle source
# File lib/humansiz.rb, line 33 def MB ; self * M ; end
MiB()
click to toggle source
# File lib/humansiz.rb, line 46 def MiB ; self * Mb ; end
TB()
click to toggle source
# File lib/humansiz.rb, line 35 def TB ; self * T ; end
TiB()
click to toggle source
# File lib/humansiz.rb, line 48 def TiB ; self * Tb ; end
d()
click to toggle source
# File lib/humansiz.rb, line 89 def d ; h * 24 ; end
h()
click to toggle source
# File lib/humansiz.rb, line 88 def h ; m * 60 ; end
kB()
click to toggle source
# File lib/humansiz.rb, line 32 def kB ; self * K ; end
kiB()
click to toggle source
# File lib/humansiz.rb, line 45 def kiB ; self * Kb ; end
m()
click to toggle source
# File lib/humansiz.rb, line 87 def m ; s * 60 ; end
s()
click to toggle source
# File lib/humansiz.rb, line 86 def s ; self ; end
to_h() → str
click to toggle source
To human readable with decimal prefixes.
4096.to_h #=> " 4.1kB"
# File lib/humansiz.rb, line 59 def to_h n = 0 s = to_f while s >= K do s /= K ; n += 1 end format = n.zero? ? "%3d " : "%5.1f" (format % s) + (PREFIXES[ n]||"?") + "B" end
to_hib() → str
click to toggle source
To human readable with binary prefixes.
4096.to_hib #=> " 4.0kiB"
# File lib/humansiz.rb, line 74 def to_hib n = 0 s = to_f while s >= Kb do s /= Kb ; n += 1 end format = n.zero? ? "%4d " : "%6.1f" (format % s) + (PREFIXES[ n]||"?") + "iB" end
w()
click to toggle source
# File lib/humansiz.rb, line 90 def w ; d * 7 ; end