Class: Zxcvbn::DictionaryRanker Private
- Inherits:
-
Object
- Object
- Zxcvbn::DictionaryRanker
- Defined in:
- lib/zxcvbn/dictionary_ranker.rb,
sig/zxcvbn/dictionary_ranker.rbs
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.
13 14 15 16 17 |
# File 'lib/zxcvbn/dictionary_ranker.rb', line 13 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).
23 24 25 26 27 28 29 |
# File 'lib/zxcvbn/dictionary_ranker.rb', line 23 def self.rank_dictionary(words) words .each_with_index .with_object({}) do |(word, i), dictionary| dictionary[CaseHelpers.downcase_preserving_length(word)] = i + 1 end end |