number_with_delimiter(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 â.â). -
:raise
- If true, raisesInvalidNumberError
when the argument is invalid.
Examples
number_with_delimiter(12345678) # => 12,345,678 number_with_delimiter("123456") # => 123,456 number_with_delimiter(12345678.05) # => 12,345,678.05 number_with_delimiter(12345678, delimiter: ".") # => 12.345.678 number_with_delimiter(12345678, delimiter: ",") # => 12,345,678 number_with_delimiter(12345678.05, separator: " ") # => 12,345,678 05 number_with_delimiter(12345678.05, locale: :fr) # => 12 345 678,05 number_with_delimiter("112a") # => 112a number_with_delimiter(98765432.98, delimiter: " ", separator: ",") # => 98 765 432,98 number_with_delimiter("112a", raise: true) # => raise InvalidNumberError
Please login to continue.