Fab.Person behaviour (fab_person v1.1.0)

Functions for generating random information about a person.

Supported Locales

  • af_ZA
  • az
  • cs_CZ
  • da
  • de
  • de_AT
  • de_CH
  • dv
  • el
  • en
  • en_AU
  • en_GB
  • en_GH
  • en_HK
  • en_IN
  • en_NG
  • en_ZA
  • es
  • fr
  • ja
  • pt_BR
  • pt_PT
  • ru
  • zh_CN

Summary

Functions

Returns a random first name.

Generates a random full name.

Returns a random last name.

Returns a random middle name.

Returns a random name prefix.

Returns a random sex.

Returns a random name suffix.

Types

sex_t()

@type sex_t() :: {:sex, :female | :male | :mixed}

Callbacks

first_name(list)

(optional)
@callback first_name([sex_t()]) :: [String.t()]

full_name(list)

(optional)
@callback full_name([sex_t()]) :: [Fab.Template.t()]

last_name(list)

(optional)
@callback last_name([sex_t()]) :: [String.t()]

middle_name(list)

(optional)
@callback middle_name([sex_t()]) :: [String.t()]

prefix(list)

(optional)
@callback prefix([sex_t()]) :: [String.t()]

sex()

(optional)
@callback sex() :: [String.t()]

suffix()

(optional)
@callback suffix() :: [String.t()]

Functions

first_name(opts \\ [])

@spec first_name([sex_t()]) :: String.t()

Returns a random first name.

Options

  • :sex – Can be :female, :male, or :mixed. Defaults to :mixed.

Examples

iex> Fab.Person.first_name()
"Laury"

iex> Fab.Person.first_name(sex: :female)
"Hazel"

iex> Fab.Person.first_name(sex: :male)
"Darryl"

full_name(opts \\ [])

@spec full_name([sex_t()]) :: String.t()

Generates a random full name.

Options

  • :first_name - First name to use. Defaults to a randomly selected name based on :sex.
  • :last_name - Last name to use. Defaults to a randomly selected name based on :sex.
  • :middle_name - Middle name to use. Defaults to a randomly selected name based on :sex.
  • :prefix - Prefix to use. Defaults to a randomly selected prefix based on :sex.
  • :sex - Sex used to generate the first and last name. Can be :female, :male or :mixed. Defaults to :mixed.
  • :suffix - Suffix to use. Defaults to a randomly selected suffix based on :sex.

Examples

iex> Fab.Person.full_name()
"Mrs. Greta Lebsack"

iex> Fab.Person.full_name(first_name: "Anthony")
"Anthony Cummings"

iex> Fab.Person.full_name(last_name: "Smith")
"Miss Waylon Smith"

iex> Fab.Person.full_name(sex: :female)
"Arlene Leffler"

iex> Fab.Person.full_name(sex: :male)
"Lyle Huel"

last_name(opts \\ [])

@spec last_name([sex_t()]) :: String.t()

Returns a random last name.

Options

  • :sex – Can be :female, :male, or :mixed. Defaults to :mixed.

Examples

iex> Fab.Person.last_name()
"Toy"

iex> Fab.Person.last_name(sex: :female)
"Rowe"

iex> Fab.Person.last_name(sex: :male)
"Cronin"

middle_name(opts \\ [])

@spec middle_name([sex_t()]) :: String.t()

Returns a random middle name.

Options

  • :sex – Can be :female, :male, or :mixed. Defaults to :mixed.

Examples

iex> Fab.Person.middle_name()
"Reign"

iex> Fab.Person.middle_name(sex: :female)
"Jolie"

iex> Fab.Person.middle_name(sex: :male)
"Monroe"

prefix(opts \\ [])

@spec prefix([sex_t()]) :: String.t()

Returns a random name prefix.

Options

  • :sex – Can be :female, :male, or :mixed. Defaults to :mixed.

Examples

iex> Fab.Person.prefix()
"Mrs."

iex> Fab.Person.prefix(sex: :female)
"Ms."

iex> Fab.Person.prefix(sex: :male)
"Mr."

sex()

@spec sex() :: String.t()

Returns a random sex.

Examples

iex> Fab.Person.sex()
"female"

suffix()

@spec suffix() :: String.t()

Returns a random name suffix.

Examples

iex> Fab.Person.suffix()
"PhD"