Sha256: 630dc80924bef27ed15b3dea80f5019e6ab22f5998e6be2a774b1612cb013f60

Contents?: true

Size: 1008 Bytes

Versions: 4

Compression:

Stored size: 1008 Bytes

Contents

# frozen_string_literal: true
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::Words["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

4 entries across 4 versions & 1 rubygems

Version Path
wordlist-1.1.0 lib/wordlist/modifiers/downcase.rb
wordlist-1.0.3 lib/wordlist/modifiers/downcase.rb
wordlist-1.0.2 lib/wordlist/modifiers/downcase.rb
wordlist-1.0.1 lib/wordlist/modifiers/downcase.rb