Class: Prime8::Generators::EratosthenesGenerator
- Inherits:
-
PrimeGenerator
- Object
- PrimeGenerator
- Prime8::Generators::EratosthenesGenerator
- Defined in:
- lib/prime_8/generators/eratosthenes_generator.rb
Instance Method Summary collapse
-
#initialize ⇒ EratosthenesGenerator
constructor
A new instance of EratosthenesGenerator.
- #rewind ⇒ Object
- #succ ⇒ Object (also: #next)
Methods inherited from PrimeGenerator
#each, #upper_bound, #upper_bound=, #with_object
Constructor Details
#initialize ⇒ EratosthenesGenerator
Returns a new instance of EratosthenesGenerator.
6 7 8 9 10 |
# File 'lib/prime_8/generators/eratosthenes_generator.rb', line 6 def initialize @last_prime_index = -1 @strategy = Prime8::Strategies.eraatosthenes super end |
Instance Method Details
#rewind ⇒ Object
17 18 19 |
# File 'lib/prime_8/generators/eratosthenes_generator.rb', line 17 def rewind initialize end |
#succ ⇒ Object Also known as: next
12 13 14 15 |
# File 'lib/prime_8/generators/eratosthenes_generator.rb', line 12 def succ @last_prime_index += 1 @strategy.get_nth_prime(@last_prime_index) end |