module ActionView::Helpers::NumberHelper

def number_to_human_size(number, options = {})

number_to_human_size(524288000, precision: 5) # => "500 MB"
number_to_human_size(1234567890123, precision: 5) # => "1.1228 TB"
number_to_human_size(1234567, precision: 2, separator: ',') # => 1,2 MB
number_to_human_size(483989, precision: 2) # => 470 KB
number_to_human_size(1234567, precision: 2) # => 1.2 MB
number_to_human_size(1234567890123456789) # => 1.07 EB
number_to_human_size(1234567890123456) # => 1.1 PB
number_to_human_size(1234567890123) # => 1.12 TB
number_to_human_size(1234567890) # => 1.15 GB
number_to_human_size(1234567) # => 1.18 MB
number_to_human_size(12345) # => 12.1 KB
number_to_human_size(1234) # => 1.21 KB
number_to_human_size(123) # => 123 Bytes

==== Examples

the argument is invalid.
* :raise - If true, raises +InvalidNumberError+ when
+true+)
insignificant zeros after the decimal separator (defaults to
* :strip_insignificant_zeros - If +true+ removes
to "").
* :delimiter - Sets the thousands delimiter (defaults
fractional and integer digits (defaults to ".").
* :separator - Sets the separator between the
digits (defaults to +true+)
of significant_digits. If +false+, the number of fractional
* :significant - If +true+, precision will be the number
(defaults to 3).
* :precision - Sets the precision of the number
(defaults to current locale).
* :locale - Sets the locale to be used for formatting

==== Options

generic number.
See number_to_human if you want to pretty-print a

customize the format in the +options+ hash.
method is useful for reporting file sizes to users. You can
representation (e.g., giving it 1500 yields 1.46 KB). This
Formats the bytes in +number+ into a more understandable
def number_to_human_size(number, options = {})
  delegate_number_helper_method(:number_to_human_size, number, options)
end