Description
The RandomText class allows you to generate different types of randomt texts. The options included are colors, names, nouns, adjectives, verbs, phrases, full names, words, phone numbers, email addresses, and texts.
Static methods
adjective
Generates a random adjective. The result value is capitalized.
staticString adjective()
- returns: String - random adjective.
color
Generates a random color name. The result value is capitalized.
staticString color()
- returns: String - random color name.
Generates a random email address.
staticString email()
- returns: String - random email address.
fullName
Generates a random person’s name, which has the following structure:
<optional prefix> <first name> <second name> <optional suffix>
staticString fullName()
- returns: String - random name.
noun
Generates a random noun. The result value is capitalized.
staticString noun()
- returns: String - random noun.
phone
Generates a random phone number. The phone number has the format: (XXX) XXX-YYYY
staticString phone()
- returns: String - random phone number.
phrase
Generates a random phrase which consists of few words separated by spaces. The first word is capitalized, others are not.
staticString phrase(int minLength, [int? maxLength])
- minLength: int - (optional) minimum string length.
- maxLength: int? - maximum string length.
- returns: String - random phrase.
text
Generates a random text, consisting of first names, last names, colors, stuffs, adjectives, verbs, and punctuation marks.
staticString text(int minLength, [int? maxLength])
- minLength: int - minimum amount of words to generate. The text will contain ‘minSize’ words if ‘maxSize’ is omitted.
- maxLength: int? - (optional) maximum amount of words to generate.
- returns: String - random text.
verb
Generates a random verb. The result value is capitalized.
staticString verb()
- returns: String - random verb.
word
Generates a random word from available first names, last names, colors, stuffs, adjectives, or verbs.
staticString word()
- returns: String - random word.
words
Generates a random word from available first names, last names, colors, stuffs, adjectives, or verbs.
staticString words(int min, [int? max])
- min: int - (optional) minimum number of words.
- max: int? - maximum number of words.
- returns: String - random text.
Examples
var value1 = RandomText.name(); // Possible result: 'Segio'
var value2 = RandomText.verb(); // Possible result: 'Run'
var value3 = RandomText.Text(50); // Possible result: 'Run jorge. Red high scream?'