Class: Integer
- Inherits:
-
Object
- Object
- Integer
- Defined in:
- lib/ext/integer.rb
Instance Method Summary collapse
- #to_filesize ⇒ Object (also: #to_file_size)
Instance Method Details
#to_filesize ⇒ Object Also known as: to_file_size
2 3 4 5 6 7 8 9 10 |
# File 'lib/ext/integer.rb', line 2 def to_filesize { 'B' => 1024, 'KB' => 1024 * 1024, 'MB' => 1024 * 1024 * 1024, 'GB' => 1024 * 1024 * 1024 * 1024, 'TB' => 1024 * 1024 * 1024 * 1024 * 1024 }.each_pair { |e, s| return "#{(self.to_f / (s / 1024)).round(2)} #{e}" if self < s } end |