Method: ApplicationHelper#short_number_to_human

Defined in:
app/helpers/application_helper.rb

#short_number_to_human(*args, **opts) ⇒ String?

Converts a number to short-form humanized display, i.e. 100,000 = 100k. Parameters as for ActiveSupport::NumberHelper#number_to_human

Returns:

  • (String, nil)

    The humanized number.



97
98
99
100
101
# File 'app/helpers/application_helper.rb', line 97

def short_number_to_human(*args, **opts)
  opts = { units: { thousand: 'k', million: 'm', billion: 'b', trillion: 't', quadrillion: 'qd' },
           format: '%n%u' }.merge(opts)
  ActiveSupport::NumberHelper.number_to_human(*args, **opts)
end