silly_seahorse v0.1.4 SillySeahorse View Source
This library will generate random usernames like “silly_seahorse” or “anxious-turtle”.
Usernames consist of an adjective and a name of an animal. Optionally, usernames can be prefixed with an adverb: e.g., “very_silly_seahorse”.
By default, there is a 50 percent chance that an adverb will be prepended to the username. This option can be disabled by passing allow_adverb: false
to generate_random/1
. It is currently not possible to customize the probability of an adverb being prepended.
The words that form the username are joined by the delimiter -
, and the maximum length of the generated usernames is 20 characters. Both can be changed by passing :delimiter
or :max_length
option to generate_random/1
.
Notes
- The smallest possible value for
:max_length
is 20. If you pass a smaller value, it will be ignored. - Custom delimiters must be a single character grapheme. Data types other than
string
are not allowed. For example,generate_random(delimiter: "ö")
will work, butgenerate_random(delimiter: 9)
will not.
Link to this section Summary
Functions
Generates a random username
Link to this section Types
opts() :: [ delimiter: String.t(), allow_adverb: boolean(), max_length: non_neg_integer() ]
Link to this section Functions
Generates a random username.
Examples
SillySeahorse.generate_random()
=> "silly-seahorse"
Options
- :delimiter - The character to use between word. Must be consisting of one grapheme. Defaults to “-“.
- :allow_adverb - If true, it will prepend an adjective to the name. If it can’t because of the max name length, it returns the originally generated username. Also, even if there are enough characters left, there is a 50 percent chance that an adverb will not be prepended. Defaults to
true
. - :max_length - The max length of the generated name. Values lower than 20 are ignored. Defaults to
20
.
Examples
SillySeahorse.generate_random(delimiter: "_")
=> "very_anxious_turtle"
SillySeahorse.generate_random(allow_adverb: false)
=> "anxious-turtle"
SillySeahorse.generate_random(max_length: 30)
=> "extremely-worried-hippopotamus"