Cldr.Unit.to_string-exclamation-mark

You're seeing just the function to_string-exclamation-mark, go back to Cldr.Unit module for more information.

Specs

to_string!(list_or_number :: value() | t() | [t()]) :: String.t() | no_return()

Formats a number into a string according to a unit definition for the current process's locale and backend or raises on error.

The curent process's locale is set with Cldr.put_locale/1.

See Cldr.Unit.to_string!/3 for full details.

Link to this function

to_string!(unit, backend, options \\ [])

View Source

Specs

to_string!(value() | t() | [t()], Cldr.backend() | Keyword.t(), Keyword.t()) ::
  String.t() | no_return()

Formats a number into a string according to a unit definition for the current process's locale and backend or raises on error.

During processing any :format_options of a t:Cldr.Unit are merged with options with options taking precedence.

Arguments

  • number is any number (integer, float or Decimal) or a t:Cldr.Unit struct

  • backend is any module that includes use Cldr and therefore is a Cldr backend module. The default is Cldr.default_backend!/0.

  • options is a keyword list

Options

Returns

  • formatted_string or

  • raises an exception

Examples

iex> Cldr.Unit.to_string! Cldr.Unit.new!(:gallon, 123), MyApp.Cldr
"123 gallons"

iex> Cldr.Unit.to_string! Cldr.Unit.new!(:gallon, 1), MyApp.Cldr
"1 gallon"

iex> Cldr.Unit.to_string! Cldr.Unit.new!(:gallon, 1), MyApp.Cldr, locale: "af"
"1 gelling"