Monetized v0.3.1 Monetized.Currency
Defines available currencies and functions to handle them.
Summary
Functions
Retrieves a struct holding all the currency options
Retrieves the currency struct for the given key
Retrieves a list of currency options keys
Attempts to parse the currency from the given string based on both the currency key and the symbol
Attempts to parse the currency from the given string based on the currency key
Attempts to guess the currency from the given string based on the currency symbol
Functions
Specs
get(String.t) :: struct
Retrieves the currency struct for the given key.
Examples
iex> Monetized.Currency.get("EUR")
%{name: "Euro", symbol: "€", key: "EUR"}
Attempts to parse the currency from the given string based on both the currency key and the symbol.
Examples
iex> Monetized.Currency.parse("EUR 200.00")
%{name: "Euro", symbol: "€", key: "EUR"}
iex> Monetized.Currency.parse("£ 200.00")
%{name: "Pound Sterling", symbol: "£", key: "GBP"}
iex> Monetized.Currency.parse("200.00 $")
%{name: "US Dollar", symbol: "$", key: "USD"}
Attempts to parse the currency from the given string based on the currency key.
Examples
iex> Monetized.Currency.parse_by_key("EUR 200.00")
%{name: "Euro", symbol: "€", key: "EUR"}
iex> Monetized.Currency.parse_by_key("200.00 USD")
%{name: "US Dollar", symbol: "$", key: "USD"}
iex> Monetized.Currency.parse_by_key("200.00 GBP")
%{name: "Pound Sterling", symbol: "£", key: "GBP"}
Attempts to guess the currency from the given string based on the currency symbol.
Examples
iex> Monetized.Currency.parse_by_symbol("€ 200.00")
%{name: "Euro", symbol: "€", key: "EUR"}
iex> Monetized.Currency.parse_by_symbol("200.00 $")
%{name: "US Dollar", symbol: "$", key: "USD"}
iex> Monetized.Currency.parse_by_symbol("£200.00")
%{name: "Pound Sterling", symbol: "£", key: "GBP"}