Sha256: 9bc85a2e502d75cbad3d6062aa20e0f66b6536924627ed58e8a14ff85504b8e6

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

require 'wordlist/modifiers/modifier'

module Wordlist
  module Modifiers
    #
    # Lazily calls `String#downcase` on every word in the wordlist.
    #
    # @since 1.0.0
    #
    class Downcase < Modifier

      #
      # Enumerates over every `downcase`d word in the wordlist.
      #
      # @yield [word]
      #   The given block will be passed each `downcase`d word.
      #
      # @yieldparam [String] word
      #   A `downcase`d word.
      #
      # @return [Enumerator]
      #   If no block is given, an Enumerator object will be returned.
      #
      # @example
      #   wordlist = Wordlist::List["Foo", "BAR", "bAz"]
      #   wordlist.downcase.each do |word|
      #     puts word
      #   end
      #   # foo
      #   # bar
      #   # baz
      #
      # @api public
      #
      def each
        return enum_for(__method__) unless block_given?

        @wordlist.each do |word|
          yield word.downcase
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wordlist-1.0.0 lib/wordlist/modifiers/downcase.rb