Sha256: 489767704affaee4e2095c07fc2b6ba161251d6fed87a1e5102ef59513ff662d

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true
require_relative '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::Words["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.1.1 lib/wordlist/modifiers/capitalize.rb