NeoFaker.Text (neo_faker v0.13.0)
View SourceFunctions for generating text.
This module provides utilities to generate random text, including alphanumeric characters and emojis.
Summary
Functions
Generates a single random character.
Generates a string of random characters.
Generates a random emoji.
Generates a random word.
Functions
Generates a single random character.
Returns a single alphanumeric character such as a letter or digit. If no options are provided, it randomly selects from the full alphanumeric set.
Options
The accepted options are:
:type- Specifies the type of character to generate.
The values for :type can be:
:alphabet_lower- A lowercase letter.:alphabet_upper- An uppercase letter.:alphabet- A letter (either lowercase or uppercase).:digit- A digit (0-9).
Examples
iex> NeoFaker.Text.character()
"a"
iex> NeoFaker.Text.character(type: :digit)
"0"
@spec characters(non_neg_integer(), Keyword.t()) :: String.t()
Generates a string of random characters.
Returns a string of the specified length containing randomly selected characters.
Options
The accepted options are:
:type- Specifies the type of character to generate.
The values for :type can be:
:alphabet_lower- A lowercase letter.:alphabet_upper- An uppercase letter.:alphabet- A letter (either lowercase or uppercase).:digit- A digit (0-9).
Examples
iex> NeoFaker.Text.characters()
"XfELJU1mRMg"
iex> NeoFaker.Text.characters(20, type: :alphabet_upper)
"BVAJHRGSCEVJFNYSWCJE"
Generates a random emoji.
Returns a random emoji from any category if no category is specified; otherwise, it selects one from the specified category.
Options
The accepted options are:
:category- Specifies the category from which to generate an emoji.
The values for :category can be:
:all- An emoji from any category (default).:activities- An emoji related to activities.:animals_and_nature- An emoji related to animals and nature.:food_and_drink- An emoji related to food and drink.:objects- An emoji related to objects.:people_and_body- An emoji related to people and body.:smileys_and_emotion- An emoji related to smileys and emotion.:symbols- An emoji related to symbols.:travel_and_places- An emoji related to travel and places.
Examples
iex> NeoFaker.Text.emoji()
"✨"
iex> NeoFaker.Text.emoji(category: :activities)
"🎉"
@spec word() :: String.t()
Generates a random word.
Returns a random word from common word lists.
Examples
iex> NeoFaker.Text.word()
"computer"