GB2260.Division

Elixir.GB2260.Division provides a struct.

Summary

Functions

Return batch of structs by list of codes

Build a struct of GB2260.Division

Return all counties of province or prefecture

Return county of specific struct

Return true if the struct is county

Return true if the struct is prefecture

Return true if the struct is province

Return prefecture of specific struct

Return all prefectures of province

Return province of specific struct

Types

t :: %GB2260.Division{code: String.t, name: String.t, revision: non_neg_integer}

Functions

batch(list, revision \\ Data.last_revision())

Specs

batch([String.t], non_neg_integer) :: [GB2260.Division.t]

Return batch of structs by list of codes.

Example

iex> GB2260.Division.batch(["110000", "110100"])
[
  %GB2260.Division{ code: "110000", name: "北京市", revision: 2014 },
  %GB2260.Division{ code: "110100", name: "市辖区", revision: 2014 }
]
iex> GB2260.Division.batch(["110000", "110100"], 2013)
[
  %GB2260.Division{ code: "110000", name: "北京市", revision: 2013 },
  %GB2260.Division{ code: "110100", name: "市辖区", revision: 2013 }
]
build(code, name, revision \\ Data.last_revision())

Specs

build(String.t, String.t, non_neg_integer) :: GB2260.Division.t

Build a struct of GB2260.Division.

Example

iex> GB2260.Division.build("110000", "北京市")
%GB2260.Division{ code: "110000", name: "北京市", revision: 2014 }
iex> GB2260.Division.build("110000", "北京市", 2013)
%GB2260.Division{ code: "110000", name: "北京市", revision: 2013 }
counties(division)

Specs

Return all counties of province or prefecture.

county(division)

Specs

Return county of specific struct.

get(code, revision \\ Data.last_revision())

Specs

get(String.t, non_neg_integer) :: GB2260.Division.t

Get the specific struct.

Example

iex> GB2260.Division.get("110000")
%GB2260.Division{ code: "110000", name: "北京市", revision: 2014 }
iex> GB2260.Division.get("110000", 2013)
%GB2260.Division{ code: "110000", name: "北京市", revision: 2013 }
is_county?(division)

Specs

is_county?(GB2260.Division.Division.t) :: boolean

Return true if the struct is county.

is_prefecture?(division)

Specs

is_prefecture?(GB2260.Division.Division.t) :: boolean

Return true if the struct is prefecture.

is_province?(division)

Specs

is_province?(GB2260.Division.Division.t) :: boolean

Return true if the struct is province.

prefecture(division)

Specs

prefecture(GB2260.Division.t) ::
  GB2260.Division.t |
  nil

Return prefecture of specific struct.

prefectures(division)

Specs

Return all prefectures of province.

province(division)

Return province of specific struct.