Dinheiro v0.1.4 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

Link to this function find(codigo) View Source
find(String.t() | atom()) :: map() | nil

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}
Link to this function get_atom(codigo) View Source
get_atom(String.t() | atom()) :: atom() | nil

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
Link to this function get_factor(codigo) View Source
get_factor(String.t() | atom()) :: float() | nil

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
Link to this function to_string(moeda, valor, opts \\ []) View Source
to_string(String.t() | atom(), float(), Keywords.t()) :: String.t()

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"