NeoFaker.Address (neo_faker v0.12.0)
View SourceFunctions for generating address-related data.
This module provides utilities to generate random addresses, including street names, city names, country names, etc.
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 an integer or a string representation of the building number.
Options
:type
- Specifies the type of the building number to return.
The values for :type
can be:
:string
- Returns the building number as a string (default).:integer
- Returns the building number as an integer.
Examples
iex> NeoFaker.Address.building_number(1..100)
"25"
iex> NeoFaker.Address.building_number(1..100, type: :integer)
25
Generates a random city name.
Returns a string representing a city name. If an option is provided, it uses the specified locale for generating the city name.
Options
The accepted options are:
:locale
- Specifies the locale to use.
Values for option :locale
can be:
nil
- Uses the default locale:default
.:id_id
- Uses the Indonesian locale, for example.
Examples
iex> NeoFaker.Address.city()
"Saint Marys City"
iex> NeoFaker.Address.city(locale: :id_id)
"Palu"
Generates random geographic coordinates.
Return a tuple of latitude and longitude, or a single value based on the specified type.
Options
The accepted options are:
:type
- Specifies which coordinate(s) to return.:precision
- Number of decimal places.
The values for :type
can be:
:full
(default) - Returns{latitude, longitude}
tuple.:latitude
- Returns only the latitude as a float.:longitude
- Returns only the longitude as a float.
The value for :precision
can be any integer (default: 6), which determines the number of
decimal places in the returned coordinates.
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}
Generates a random country name.
This function behaves similarly to city/1
, but it generates a random country name instead.