SoftBank.Note.to_string
You're seeing just the function
to_string
, go back to SoftBank.Note module for more information.
Specs
Converts a SoftBank.Note
struct to a string representation
The following options are available:
separator
- default","
, sets the separator for groups of thousands. "1,000"delimeter
- default"."
, sets the decimal delimeter. "1.23"symbol
- defaulttrue
, sets whether to display the currency symbol or not.symbol_on_right
- defaultfalse
, display the currency symbol on the right of the number, eg: 123.45€symbol_space
- defaultfalse
, add a space between currency symbol and number, eg: € 123,45 or 123.45 €fractional_unit
- defaulttrue
, show the remaining units after the delimeter
Example:
iex> SoftBank.Note.to_string(SoftBank.Note.new(123456, :GBP))
"£1,234.56"
iex> SoftBank.Note.to_string(SoftBank.Note.new(123456, :EUR), separator: ".", delimeter: ",")
"€1.234,56"
iex> SoftBank.Note.to_string(SoftBank.Note.new(123456, :EUR), symbol: false)
"1,234.56"
iex> SoftBank.Note.to_string(SoftBank.Note.new(123456, :EUR), symbol: false, separator: "")
"1234.56"
iex> SoftBank.Note.to_string(SoftBank.Note.new(123456, :EUR), fractional_unit: false)
"€1,234"
It can also be interpolated (It implements the String.Chars protocol)
To control the formatting, you can use the above options in your config,
more information is in the introduction to SoftBank.Note
Example:
iex> "Total: #{SoftBank.Note.new(100_00, :USD)}"
"Total: $100.00"