Class: PassGen::Memorable::Dictionary

Inherits:
Object
  • Object
show all
Defined in:
lib/passgen/memorable.rb

Overview

Constant Summary collapse

PATHS =
%w(/usr/share/dict/words /usr/share/words)

Instance Method Summary collapse

Instance Method Details

#get_wordsObject



46
47
48
49
50
# File 'lib/passgen/memorable.rb', line 46

def get_words
  File.readlines(PATHS.first).select { |word| word.length < 6 }
rescue Errno::ENOENT
  File.readlines(PATHS.last).select { |word| word.length < 6 }
end

#randomObject



41
42
43
44
# File 'lib/passgen/memorable.rb', line 41

def random
  words = get_words
  words[rand(words.length)].chomp
end