Class: Wordlist::Operators::Power
- Inherits:
-
BinaryOperator
- Object
- Operator
- BinaryOperator
- Wordlist::Operators::Power
- Defined in:
- lib/wordlist/operators/power.rb
Overview
Lazily enumerates over every combination of words in the wordlist.
Instance Attribute Summary collapse
-
#wordlists ⇒ Product
readonly
The product of the wordlist with itself.
Attributes inherited from BinaryOperator
Instance Method Summary collapse
-
#each {|string| ... } ⇒ Enumerator
Enumerates over every combination of words from the wordlist.
-
#initialize(wordlist, exponent) ⇒ Power
constructor
Initializes the power operator.
Constructor Details
#initialize(wordlist, exponent) ⇒ Power
Initializes the power operator.
28 29 30 31 32 33 34 35 36 |
# File 'lib/wordlist/operators/power.rb', line 28 def initialize(wordlist,exponent) super(wordlist,exponent) @wordlists = wordlist (exponent - 1).times do @wordlists = Product.new(wordlist,@wordlists) end end |
Instance Attribute Details
#wordlists ⇒ Product (readonly)
The product of the wordlist with itself.
17 18 19 |
# File 'lib/wordlist/operators/power.rb', line 17 def wordlists @wordlists end |
Instance Method Details
#each {|string| ... } ⇒ Enumerator
Enumerates over every combination of words from the wordlist.
67 68 69 |
# File 'lib/wordlist/operators/power.rb', line 67 def each(&block) @wordlists.each(&block) end |