Functions for generating random address data.
Provides utilities to generate street names, city names, country names, building numbers, and geographic coordinates with support for multiple locales.
Summary
Functions
Generates a random building number within a specified range.
Generates a random city name.
Generates random geographic coordinates.
Generates a random country name.
Functions
Generates a random building number within a specified range.
Returns the building number as a string by default, or as an integer when
type: :integer is passed.
Parameters
range- The range of building numbers. Defaults to1..100.opts- Keyword list of options::type- Return type. Either:string(default) or:integer.
Examples
iex> NeoFaker.Address.building_number()
"42"
iex> NeoFaker.Address.building_number(1..100, type: :integer)
25
Generates a random city name.
The city name is selected from locale-specific data. Pass locale: to use a
different locale. See the
available locales
for supported codes.
Examples
iex> NeoFaker.Address.city()
"Saint Marys City"
iex> NeoFaker.Address.city(locale: :id_id)
"Palu"
Generates random geographic coordinates.
Returns a {latitude, longitude} tuple by default. Use the :type option to
return a single value, and :precision to control decimal places.
Parameters
opts- Keyword list of options::type- Which coordinate(s) to return. Defaults to:full.:precision- Number of decimal places. Defaults to6.
Options
The values for :type can be:
:full- Returns{latitude, longitude}tuple (default).:latitude- Returns only the latitude as a float.:longitude- Returns only the longitude as a float.
Examples
iex> NeoFaker.Address.coordinate()
{11.5831672, 165.3662683}
iex> NeoFaker.Address.coordinate(type: :latitude)
11.5831672
iex> NeoFaker.Address.coordinate(type: :longitude)
165.3662683
iex> NeoFaker.Address.coordinate(precision: 2)
{11.58, 165.37}
iex> NeoFaker.Address.coordinate(type: :latitude, precision: 4)
11.5832
Generates a random country name.
The country name is selected from locale-specific data. Pass locale: to use a
different locale. See the
available locales
for supported codes.
Examples
iex> NeoFaker.Address.country()
"United States"
iex> NeoFaker.Address.country(locale: :id_id)
"Indonesia"