number_to_delimited

number_to_delimited(number, options = {})
Instance Public methods

Formats a number with grouped thousands using delimiter (e.g., 12,324). You can customize the format in the options hash.

Options

  • :locale - Sets the locale to be used for formatting (defaults to current locale).

  • :delimiter - Sets the thousands delimiter (defaults to â,â).

  • :separator - Sets the separator between the fractional and integer digits (defaults to â.â).

Examples

number_to_delimited(12345678)                    # => 12,345,678
number_to_delimited('123456')                    # => 123,456
number_to_delimited(12345678.05)                 # => 12,345,678.05
number_to_delimited(12345678, delimiter: '.')    # => 12.345.678
number_to_delimited(12345678, delimiter: ',')    # => 12,345,678
number_to_delimited(12345678.05, separator: ' ') # => 12,345,678 05
number_to_delimited(12345678.05, locale: :fr)    # => 12 345 678,05
number_to_delimited('112a')                      # => 112a
number_to_delimited(98765432.98, delimiter: ' ', separator: ',')
# => 98 765 432,98
doc_ruby_on_rails
2015-06-20 00:00:00
Comments
Leave a Comment

Please login to continue.