method
convert
v4.2.1 -
Show latest stable
- Class:
ActiveSupport::NumberHelper::NumberToHumanConverter
convert()public
No documentation available.
# File activesupport/lib/active_support/number_helper/number_to_human_converter.rb, line 11
def convert # :nodoc:
@number = Float(number)
# for backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files
unless options.key?(:strip_insignificant_zeros)
options[:strip_insignificant_zeros] = true
end
units = opts[:units]
exponent = calculate_exponent(units)
@number = number / (10 ** exponent)
unit = determine_unit(units, exponent)
rounded_number = NumberToRoundedConverter.convert(number, options)
format.gsub(/%n/, rounded_number).gsub(/%u/, unit).strip
end