Countriex v0.3.0 Countriex

Provides all sorts useful information for every country in the ISO 3166 standard, and helper methods to filter/retrieve that information by.

Summary

Functions

Returns all country data

Returns all countries matching the given criteria, or [] if the criteria does not match any countries

Returns the first matching country with the given criteria, or nil if a country with that data does not exist

Functions

all()

Returns all country data

filter(field, value)

Returns all countries matching the given criteria, or [] if the criteria does not match any countries

Examples

iex> c = Countriex.filter(:region, "Americas")
iex> c |> List.first |> Map.get(:name)
"Antigua and Barbuda"
iex> c |> length
57

iex> Countriex.filter(:region, "foo")
[]
get_by(field, value)

Returns the first matching country with the given criteria, or nil if a country with that data does not exist.

Examples

iex> c = Countriex.get_by(:alpha2, "US")
iex> c.name
"United States of America"

iex> Countriex.get_by(:alpha2, "XX")
nil

iex> Countriex.get_by(:foo, "XX")
nil