Sha256: d8ec8e1a2ed98f82cb1fce351e2348154bc2c3c2496f3a1afb869635533bcd68

Contents?: true

Size: 963 Bytes

Versions: 1

Compression:

Stored size: 963 Bytes

Contents

require 'wordlist/modifiers/modifier'

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

      #
      # Enumerates over every `upcase`d word in the wordlist.
      #
      # @yield [word]
      #   The given block will be passed each `upcase`d word.
      #
      # @yieldparam [String] word
      #   A `upcase`d word.
      #
      # @return [Enumerator]
      #   If no block is given, an Enumerator object will be returned.
      #
      # @example
      #   wordlist = Wordlist::List["foo", "bar", "baz"]
      #   wordlist.upcase.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.upcase
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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