Cldr.Currency.new
You're seeing just the function
new, go back to Cldr.Currency module for more information.
Specs
Returns a Currency struct created from the arguments.
Arguments
currencyis a private use currency code in a format defined by ISO4217 which isXfollowed by two alphanumeric characters.optionsis a map of options representing the optional elements of theCldr.Currency.tstruct.
Options
:nameis the name of the currenct. Required.:digitsis the precision of the currency. Required.:symbolis the currency symbol. Optional.:narrow_symbolis an alternative narrow symbol. Optional.:round_nearestis the rounding precision such as0.05. Optional.:alt_codeis an alternative currency code for application use.:cash_digitsis the precision of the currency when used as cash. Optional.:cash_round_nearestis the rounding precision when used as cash such as0.05. Optional.
Returns
{:ok, Cldr.Currency.t}or{:error, {exception, message}}
Example
iex> Cldr.Currency.new(:XAC, name: "XAC currency", digits: 0)
{:ok,
%Cldr.Currency{
alt_code: :XAC,
cash_digits: 0,
cash_rounding: nil,
code: :XAC,
count: %{other: "XAC currency"},
digits: 0,
from: nil,
iso_digits: 0,
name: "XAC currency",
narrow_symbol: nil,
rounding: 0,
symbol: "XAC",
tender: false,
to: nil
}}
iex> Cldr.Currency.new(:XBC)
{:error, {Cldr.CurrencyAlreadyDefined, "Currency :XBC is already defined."}}
iex> MyApp.Cldr.Currency.new(:XAB, name: "Private Use Name")
{:error, "Required options are missing. Required options are [:name, :digits]"}
iex> Cldr.Currency.new(:ZAA, name: "Invalid Private Use Name", digits: 0)
{:error, {Cldr.UnknownCurrencyError, "The currency :ZAA is invalid"}}