Class: Wordlist::Operators::Concat

Inherits:
BinaryOperator show all
Defined in:
lib/wordlist/operators/concat.rb

Overview

Lazily enumerates over the first wordlist, then the second.

Since:

  • 1.0.0

Instance Attribute Summary

Attributes inherited from BinaryOperator

#left, #right

Instance Method Summary collapse

Methods inherited from BinaryOperator

#initialize

Constructor Details

This class inherits a constructor from Wordlist::Operators::BinaryOperator

Instance Method Details

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

Enumerates over each word in both wordlists.

Examples:

wordlist1 = Wordlist::Words["foo", "bar", "baz"]
wordlist2 = Wordlist::Words["abc", "xyz"]
(wordlist1 + wordlist2).each do |word|
  puts word
end
# foo
# bar
# baz
# abc
# xyz

Yields:

  • (word)

    The given block will be passed each word from both wordlists.

Yield Parameters:

  • word (String)

    A word from one of the wordlists.

Returns:

  • (Enumerator)

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

Since:

  • 1.0.0



39
40
41
42
43
44
# File 'lib/wordlist/operators/concat.rb', line 39

def each(&block)
  return enum_for(__method__) unless block

  @left.each(&block)
  @right.each(&block)
end