Skip to content

JakeStaTeresa/Currencies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Currencies Build Status Coverage Status hex.pm version hex.pm downloads

Currencies is a collection of all sorts of useful information for every currency in the ISO 4217 standard.

Installation

Add currencies to your list of dependencies in mix.exs:

def deps do
  [{:currencies, "~> 0.5.1"}]
end

After you are done, run mix deps.get in your shell to fetch and compile Currencies.

Usage

Get all Currencies.

Currencies.all |>
  Enum.count
# 162

Gets all currencies matching a currency code or iso numeric code

Currencies.all(["aud", :sgd, 51, %{}])
  |> Enum.map(fn(item) ->
      case item do
        :not_found -> :not_found
        item -> item.name
      end
    end)
# ["Australia Dollar",
#  "Singapore Dollar",
#  "Armenia Dram",
#  :not_found]

Find currency by code.

Currencies.get("AUD") # Currencies.get(:aud) also supported
# %Currencies.Currency{central_bank: %Currencies.CentralBank{name: "Reserve Bank of Australia",
#   url: "http://www.rba.gov.au"}, code: "AUD", display: "$",
#  minor_unit: %Currencies.MinorUnit{name: "Cent", size: "1/100", symbol: "c"},
#  name: "Australia Dollar", nicknames: ["Buck", "Dough"],
#  representations: %Currencies.Representations{html: "$",
#   unicode_decimal: '$'},
#  users: ["Australia", "Christmas Island", "Cocos (Keeling) Islands", "Kiribati",
#   "Nauru", "Norfolk Island", "Ashmore and Cartier Islands",
#   "Australian Antarctic Territory", "Coral Sea Islands", "Heard Island",
#   "McDonald Islands"]}

Find currency by iso numeric code

Currencies.get(36)
# %Currencies.Currency{central_bank: %Currencies.CentralBank{name: "Reserve Bank of Australia",
#   url: "http://www.rba.gov.au"}, code: "AUD", display: "$",
#  minor_unit: %Currencies.MinorUnit{name: "Cent", size: "1/100", symbol: "c"},
#  name: "Australia Dollar", nicknames: ["Buck", "Dough"],
#  representations: %Currencies.Representations{html: "$",
#   unicode_decimal: '$'},
#  users: ["Australia", "Christmas Island", "Cocos (Keeling) Islands", "Kiribati",
#   "Nauru", "Norfolk Island", "Ashmore and Cartier Islands",
#   "Australian Antarctic Territory", "Coral Sea Islands", "Heard Island",
#   "McDonald Islands"]}

Find currency by filtering through the list of currencies.

Currencies.filter(&(String.contains?(&1.name, "Peso"))) |>
  Enum.map(&(&1.name))
# ["Argentina Peso", "Chile Peso", "Colombia Peso", "Cuba Convertible Peso", "Cuba Peso",
# "Dominican Republic Peso", "Mexico Peso", "Philippines Peso", "Uruguay Peso"]
Currencies.filter(&(String.contains?(&1.name, "Peso"))) |>
  Enum.map(&(&1.name)) |>
  Enum.count
# 9

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Currency handling library for Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages