silly_seahorse v0.1.2 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
.
Additionally, words are joined by the delimiter _
and the max length of the
generated usernames is 20 characters. Both of these options can be changed by passing
:delimiter
or :max_length
to generate_random/1
.
Note that the smallest value for :max_length
is 20. If you pass a smaller value,
it will be ignored.
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. Default is “_”.
- :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. Default is true.
- :max_length - The max length of the generated name. Values lower than 20 are ignored. Default is 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"