Method: Wordlist::Modifiers::Mutate#each
- Defined in:
- lib/wordlist/modifiers/mutate.rb
#each {|word| ... } ⇒ Enumerator
Enumerates over every mutation of every word in the wordlist.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/wordlist/modifiers/mutate.rb', line 42 def each return enum_for(__method__) unless block_given? @wordlist.each do |word| yield word matches = all_matches(word) each_combination(matches) do |selected_matches| new_word = word.dup offset = 0 selected_matches.each do |match| index, end_index = match.offset(0) length = end_index - index matched_string = match[0] replace_string = substitute(matched_string) new_word[index+offset,length] = replace_string offset += (replace_string.length - length) end yield new_word end end end |