Class: PopCap::Formatters::Filesize
- Defined in:
- lib/pop_cap/formatters/filesize.rb
Overview
Public: This class formats a filesize as human readable, following a UNIX formatting standard.
filesize - Provide a filesize as string, integer, or float.
Instance Attribute Summary
Attributes inherited from Formatter
Instance Method Summary collapse
-
#format ⇒ Object
Public: This method will format the filesize.
Methods inherited from Formatter
format, #initialize, subclasses, subclasses_demodulized
Constructor Details
This class inherits a constructor from PopCap::Formatters::Formatter
Instance Method Details
#format ⇒ Object
Public: This method will format the filesize. It raises a warning message if size is greater than 999 terabytes.
Examples
fs = Filesize.new(12345678)
fs.format
# => '11.8M'
22 23 24 25 26 |
# File 'lib/pop_cap/formatters/filesize.rb', line 22 def format return if value.to_i == 0 return if too_large? converted_filesize.to_s + measurement_character end |