Class: Zxcvbn::DictionaryRanker

Inherits:
Object
  • Object
show all
Defined in:
lib/zxcvbn/dictionary_ranker.rb

Class Method Summary collapse

Class Method Details

.rank_dictionaries(lists) ⇒ Object



5
6
7
8
9
# File 'lib/zxcvbn/dictionary_ranker.rb', line 5

def self.rank_dictionaries(lists)
  lists.transform_values do |words|
    rank_dictionary(words)
  end
end

.rank_dictionary(words) ⇒ Object



11
12
13
14
15
# File 'lib/zxcvbn/dictionary_ranker.rb', line 11

def self.rank_dictionary(words)
  words
    .each_with_index
    .with_object({}) { |(word, i), dictionary| dictionary[word.downcase] = i + 1 }
end