Sha256: c7783ad5a08467fac3a5d4364dcc05d4112cd9456232f205b11c3b4cfe48d146

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true
require_relative '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

1 entries across 1 versions & 1 rubygems

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