Class: Float
- Inherits:
-
Object
- Object
- Float
- Defined in:
- lib/zypper/onlinesearch/utils.rb
Instance Method Summary collapse
Instance Method Details
#to_human ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/zypper/onlinesearch/utils.rb', line 30 def to_human conv = { 1024=>'B', 1024*1024=>'KB', 1024*1024*1024=>'MB', 1024*1024*1024*1024=>'GB', 1024*1024*1024*1024*1024=>'TB', 1024*1024*1024*1024*1024*1024=>'PB', 1024*1024*1024*1024*1024*1024*1024=>'EB' } conv.keys.sort.each { |mult| next if self >= mult suffix=conv[mult] return "%.2f %s" % [ self / (mult / 1024), suffix ] } end |