Class: Wordlist::Operators::Intersect
- Inherits:
-
BinaryOperator
- Object
- Operator
- BinaryOperator
- Wordlist::Operators::Intersect
- Defined in:
- lib/wordlist/operators/intersect.rb
Overview
Lazily enumerates over every word that belongs to both wordlists.
Instance Attribute Summary
Attributes inherited from BinaryOperator
Instance Method Summary collapse
-
#each {|word| ... } ⇒ Enumerator
Enumerates over the intersection between two wordlists.
Methods inherited from BinaryOperator
Constructor Details
This class inherits a constructor from Wordlist::Operators::BinaryOperator
Instance Method Details
#each {|word| ... } ⇒ Enumerator
Enumerates over the intersection between two wordlists.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/wordlist/operators/intersect.rb', line 38 def each return enum_for(__method__) unless block_given? unique_filter = UniqueFilter.new @left.each do |word| unique_filter.add(word) end @right.each do |word| if unique_filter.include?(word) yield word end end end |