Class: Password
- Inherits:
-
Object
- Object
- Password
- Defined in:
- lib/readable_password_generator.rb
Constant Summary collapse
- VOWELS =
%w(a e i o u y)- CONSONANTS =
%w(b c d f g h j k l m n p r s t v w x z)- DOUBLE_CONSONANTS =
%w(ch cr fr nd ng nk nt ph pr rd sh sl sp st th tr)- DEFAULT_LENGTH =
8
Instance Method Summary collapse
Instance Method Details
#generate(length = DEFAULT_LENGTH) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/readable_password_generator.rb', line 8 def generate(length = DEFAULT_LENGTH) length = validate_length(length) vowel_position = [1,2].sample size, password = length, "" char_set = 1 size.times do |char| password << pick_letter(char_set.odd?, vowel_position) char_set+=1 end password = password[0...size] end |