Class: Faker::String

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/string.rb

Constant Summary

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale

Class Method Details

.random(length: 32) ⇒ String

Produces a random UTF-8 string with optional nested length selectors.

Examples:

Faker::String.random #=> "3 뇦\u0017&y\u{3A109}$8^4* 녹豿4좘툢ꔾ쉙6ɉ\uA6 8TN畀챵|\"3쇤Ŵ"
Faker::String.random(length: 4) #=> "⼨%0*"
Faker::String.random(length: 3..12) #=> "\u{69FDC};秨툫"
Faker::String.random(length: [0, 6]) #=> "I轤𣴒P溟L"
Faker::String.random(length: [1, (2..5), [3, 6], nil]) #=> "葓L#ћ"

Parameters:

  • length (Integer, Range, Array<Integer, Range, nil>) (defaults to: 32)

    The length of produced string and/or specific UTF-8 characters to use.

Returns:



20
21
22
# File 'lib/faker/default/string.rb', line 20

def random(length: 32)
  utf8string select_a length
end