Class: Facter::BytesToHumanReadable
- Inherits:
-
Object
- Object
- Facter::BytesToHumanReadable
- Defined in:
- lib/facts_utils/bytes_to_human_readable.rb
Class Method Summary collapse
Class Method Details
.convert(bytes) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/facts_utils/bytes_to_human_readable.rb', line 6 def convert(bytes) return unless bytes return bytes.to_s + ' bytes' if bytes < 1024 units = %w[K M G T P E] result = determine_exponent(bytes) return bytes.to_s + ' bytes' if result[:exp] > units.size converted_number = pad_number(result[:converted_number]) converted_number + " #{units[result[:exp] - 1]}iB" end |