Sha256: ff2015ae1aed8b683b6e33e21592459bcace2971ad926a0eaffa33f615a9729e
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require_relative 'sub' module Wordlist module Modifiers # # Lazily calls `String#gsub` on every word in the wordlist. # # @since 1.0.0 # class Gsub < Sub # # Enumerates over every `gsub`ed word in the wordlist. # # @yield [word] # The given block will be passed each `gsub`ed word. # # @yieldparam [String] word # A `gsub`ed word from the wordlist. # # @return [Enumerator] # If no block is given, an Enumerator object will be returned. # # @example # wordlist = Wordlist::Words["Foo", "BAR", "bAz"] # wordlist.gsub(/o/,'0').each do |word| # puts word # end # # f00 # # bar # # baz # # @api public # 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wordlist-1.1.1 | lib/wordlist/modifiers/gsub.rb |