Class: Wordlist::Modifiers::Upcase

Inherits:
Modifier
  • Object
show all
Defined in:
lib/wordlist/modifiers/upcase.rb

Overview

Lazily calls String#upcase on every word in the wordlist.

Since:

  • 1.0.0

Instance Attribute Summary

Attributes inherited from Modifier

#wordlist

Instance Method Summary collapse

Methods inherited from Modifier

#initialize

Constructor Details

This class inherits a constructor from Wordlist::Modifiers::Modifier

Instance Method Details

#each {|word| ... } ⇒ Enumerator

Enumerates over every upcased word in the wordlist.

Examples:

wordlist = Wordlist::Words["foo", "bar", "baz"]
wordlist.upcase.each do |word|
  puts word
end
# FOO
# BAR
# BAZ

Yields:

  • (word)

    The given block will be passed each upcased word.

Yield Parameters:

  • word (String)

    A upcased word.

Returns:

  • (Enumerator)

    If no block is given, an Enumerator object will be returned.

Since:

  • 1.0.0



36
37
38
39
40
41
42
# File 'lib/wordlist/modifiers/upcase.rb', line 36

def each
  return enum_for(__method__) unless block_given?

  @wordlist.each do |word|
    yield word.upcase
  end
end