Class: Faker::Alphanumeric
- Defined in:
- lib/faker/default/alphanumeric.rb
Constant Summary collapse
- ALPHABET =
('a'..'z').to_a
- ALPHANUMS =
ALPHABET + (0..9).to_a
Constants inherited from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary collapse
Methods inherited from Base
bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.alpha(char_count = 32) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/faker/default/alphanumeric.rb', line 9 def alpha(char_count = 32) char_count = resolve(char_count) return '' if char_count.to_i < 1 Array.new(char_count) { sample(ALPHABET) }.join end |
.alphanumeric(char_count = 32) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/faker/default/alphanumeric.rb', line 16 def alphanumeric(char_count = 32) char_count = resolve(char_count) return '' if char_count.to_i < 1 Array.new(char_count) { sample(ALPHANUMS) }.join end |