Class: Integer
- Inherits:
-
Object
- Object
- Integer
- Defined in:
- lib/ayadn/extend.rb
Instance Method Summary collapse
Instance Method Details
#to_filesize ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/ayadn/extend.rb', line 8 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 |