Class: PwdGen::PasswordGenerator
- Inherits:
-
Object
- Object
- PwdGen::PasswordGenerator
- Defined in:
- lib/ngrams/pwdgen.rb
Instance Method Summary collapse
- #generate(length) ⇒ Object
- #generate_n(n, length) ⇒ Object
-
#initialize(file = Dictionary::DEFAULT_STORE) ⇒ PasswordGenerator
constructor
A new instance of PasswordGenerator.
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 |