Method: Wordlist::ListMethods#gsub

Defined in:
lib/wordlist/list_methods.rb

#gsub(pattern, replace = nil) {|match| ... } ⇒ Gsub

Lazily calls String#gsub on each word in the wordlist.

Examples:

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

Parameters:

  • pattern (Regexp, String)

    The pattern to replace.

  • replace (String, Hash, nil) (defaults to: nil)

    The characters or character range to use as the replacement.

Yields:

  • (match)

    The given block will be call to replace the matched substring, if replace is nil.

Yield Parameters:

  • match (String)

    A matched substring.

Returns:

  • (Gsub)

    The lazy String#gsub modification of the wordlist.

Since:

  • 1.0.0



310
311
312
313
314
315
316
# File 'lib/wordlist/list_methods.rb', line 310

def gsub(pattern,replace=nil,&block)
  if replace
    Modifiers::Gsub.new(self,pattern,replace,&block)
  else
    Modifiers::Gsub.new(self,pattern,&block)
  end
end