Cadastre v0.1.3 Cadastre.Country View Source

Country implementation

Link to this section Summary

Functions

Returns all countries

Return all ids (ISO_3166-1)

Returns country name translation for locale

Returns %Cadastre.Country{} for valid id. Returns nil for invalid id.

Link to this section Types

Link to this type

id()

View Source
id() :: <<_::16>>
Link to this type

t()

View Source
t() :: %Cadastre.Country{id: id(), name: Cadastre.msgid()}

Link to this section Functions

Returns all countries

Examples

iex> Cadastre.Country.all() |> Enum.take(3)
[
  %Cadastre.Country{id: "AD", name: "Andorra"},
  %Cadastre.Country{id: "AE", name: "United Arab Emirates"},
  %Cadastre.Country{id: "AF", name: "Afghanistan"}
]

iex> Cadastre.Country.all() |> Enum.count()
249

Return all ids (ISO_3166-1)

Examples

iex> Cadastre.Country.ids() |> Enum.take(10)
["AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR"]

Returns country name translation for locale

Examples

iex> Cadastre.Country.new("NL") |> Cadastre.Country.name("be")
"Нідэрланды"

iex> Cadastre.Country.new("NL") |> Cadastre.Country.name(":)")
"Netherlands"

iex> Cadastre.Country.name("something wrong", "be")
nil
Link to this function

new(id)

View Source
new(id() | any()) :: t() | nil

Returns %Cadastre.Country{} for valid id. Returns nil for invalid id.

Examples

iex> Cadastre.Country.new("NL")
%Cadastre.Country{id: "NL", name: "Netherlands"}

iex> Cadastre.Country.new("nl")
%Cadastre.Country{id: "NL", name: "Netherlands"}

iex> Cadastre.Country.new("xx")
nil