Class: Wordlist::Modifiers::Gsub
- Defined in:
- lib/wordlist/modifiers/gsub.rb
Overview
Lazily calls String#gsub
on every word in the wordlist.
Instance Attribute Summary
Attributes inherited from Sub
Attributes inherited from Modifier
Instance Method Summary collapse
-
#each {|word| ... } ⇒ Enumerator
Enumerates over every
gsub
ed word in the wordlist.
Methods inherited from Sub
Methods inherited from Modifier
Constructor Details
This class inherits a constructor from Wordlist::Modifiers::Sub
Instance Method Details
#each {|word| ... } ⇒ Enumerator
Enumerates over every gsub
ed word in the wordlist.
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 |