Dinheiro v0.1.3 Moeda View Source
Documentation for Moeda.
Link to this section Summary
Functions
Return a map from an atom or string that represents an ISO 4217 code
Return an atom from a value that represents an ISO 4217 code
Return a multiplication factor from an ISO 4217 code
Return a formated string from a ISO 4217 code and a float value
Link to this section Functions
Return a map from an atom or string that represents an ISO 4217 code.
Examples
iex> Moeda.find(:BRL)
%{nome: "Brazilian Real", simbolo: "R$", codigo: "BRL", codigo_iso: 986, expoente: 2}
iex> Moeda.find("BRL")
%{nome: "Brazilian Real", simbolo: "R$", codigo: "BRL", codigo_iso: 986, expoente: 2}
iex> Moeda.find("")
nil
Its function ignore case sensitive.
Examples
iex> Moeda.find(:brl)
%{nome: "Brazilian Real", simbolo: "R$", codigo: "BRL", codigo_iso: 986, expoente: 2}
iex> Moeda.find("brl")
%{nome: "Brazilian Real", simbolo: "R$", codigo: "BRL", codigo_iso: 986, expoente: 2}
Return an atom from a value that represents an ISO 4217 code.
Examples
iex> Moeda.get_atom(:BRL)
:BRL
iex> Moeda.get_atom("BRL")
:BRL
iex> Moeda.get_atom("")
nil
Its function ignore case sensitive.
Examples
iex> Moeda.get_atom(:brl)
:BRL
iex> Moeda.get_atom("brl")
:BRL
Return a multiplication factor from an ISO 4217 code.
Examples
iex> Moeda.get_factor(:BRL)
100.0
iex> Moeda.get_factor("BRL")
100.0
iex> Moeda.get_factor("")
nil
Its function ignore case sensitive.
Examples
iex> Moeda.get_factor(:brl)
100.0
iex> Moeda.get_factor("brl")
100.0
Return a formated string from a ISO 4217 code and a float value.
Examples
iex> Moeda.to_string(:BRL, 100.0)
"R$ 100,00"
iex> Moeda.to_string("BRL", 1000.5)
"R$ 1.000,50"
iex> Moeda.to_string(:BRL, -1.0)
"R$ -1,00"
Its function ignore case sensitive.
Examples
iex> Moeda.to_string(:bRl, 100.0)
"R$ 100,00"
iex> Moeda.to_string("BrL", 1000.5)
"R$ 1.000,50"
Using options-style parameters you can change the behavior of the function.
thousand_separator
- default"."
, sets the thousand separator.decimal_separator
- default","
, sets the decimal separator.
Exemples
iex> Moeda.to_string(:USD, 1000.5, thousand_separator: ",", decimal_separator: ".")
"$ 1,000.50"