Method: Wordlist::Modifiers::Gsub#each

Defined in:
lib/wordlist/modifiers/gsub.rb

#each {|word| ... } ⇒ Enumerator

Enumerates over every gsubed word in the wordlist.

Examples:

wordlist = Wordlist::Words["Foo", "BAR", "bAz"]
wordlist.gsub(/o/,'0').each do |word|
  puts word
end
# f00
# bar
# baz

Yields:

  • (word)

    The given block will be passed each gsubed word.

Yield Parameters:

  • word (String)

    A gsubed word from the wordlist.

Returns:

  • (Enumerator)

    If no block is given, an Enumerator object will be returned.

Since:

  • 1.0.0



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/wordlist/modifiers/gsub.rb', line 36

def each
  return enum_for(__method__) unless block_given?

  if @replace
    @wordlist.each do |word|
      yield word.gsub(@pattern,@replace)
    end
  else
    @wordlist.each do |word|
      yield word.gsub(@pattern,&block)
    end
  end
end