Sha256: 13460fbde529b25eb8bad8e8326b0a02afbff6e82fcb5806fe024cf2ac3bf90b

Contents?: true

Size: 1003 Bytes

Versions: 1

Compression:

Stored size: 1003 Bytes

Contents

require 'wordlist/modifiers/modifier'

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

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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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