Class: Zxcvbn::DictionaryRanker Private
- Inherits:
-
Object
- Object
- Zxcvbn::DictionaryRanker
- Defined in:
- lib/zxcvbn/dictionary_ranker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Converts raw word lists into frequency-ranked dictionaries for matcher use.
Class Method Summary collapse
-
.rank_dictionaries(lists) ⇒ Hash{Symbol => Hash{String => Integer}}
private
Ranks multiple word lists, returning a hash of ranked dictionaries.
-
.rank_dictionary(words) ⇒ Hash{String => Integer}
private
Ranks a single word list; rank starts at 1 (most common).
Class Method Details
.rank_dictionaries(lists) ⇒ Hash{Symbol => Hash{String => Integer}}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Ranks multiple word lists, returning a hash of ranked dictionaries.
11 12 13 14 15 |
# File 'lib/zxcvbn/dictionary_ranker.rb', line 11 def self.rank_dictionaries(lists) lists.transform_values do |words| rank_dictionary(words) end end |
.rank_dictionary(words) ⇒ Hash{String => Integer}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Ranks a single word list; rank starts at 1 (most common).
21 22 23 24 25 |
# File 'lib/zxcvbn/dictionary_ranker.rb', line 21 def self.rank_dictionary(words) words .each_with_index .with_object({}) { |(word, i), dictionary| dictionary[word.downcase] = i + 1 } end |