Class: PwdGen::PasswordGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/ngrams/pwdgen.rb

Instance Method Summary collapse

Constructor Details

#initialize(file = Dictionary::DEFAULT_STORE) ⇒ PasswordGenerator

Returns a new instance of PasswordGenerator.



8
9
10
# File 'lib/ngrams/pwdgen.rb', line 8

def initialize( file = Dictionary::DEFAULT_STORE )
  @ngs = Dictionary.load( file )
end

Instance Method Details

#generate(length) ⇒ Object



16
17
18
# File 'lib/ngrams/pwdgen.rb', line 16

def generate( length )
  @ngs.word( length )
end

#generate_n(n, length) ⇒ Object



12
13
14
# File 'lib/ngrams/pwdgen.rb', line 12

def generate_n( n, length )
  Array.new( n, nil ).map { |_| generate( length ) }
end