Class: Prime::EratosthenesGenerator
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
PseudoPrimeGenerator
|
|
Instance Chain:
self,
PseudoPrimeGenerator,
Enumerable
|
|
Inherits: |
Prime::PseudoPrimeGenerator
|
Defined in: | lib/prime.rb |
Overview
An implementation of PseudoPrimeGenerator.
Uses EratosthenesSieve.
Class Method Summary
Instance Attribute Summary
PseudoPrimeGenerator - Inherited
Instance Method Summary
PseudoPrimeGenerator - Inherited
#each | Iterates the given block for each prime number. |
#next | alias of #succ. |
#rewind | Rewinds the internal position for enumeration. |
#size, | |
#succ | returns the next pseudo-prime number, and move the internal position forward. |
#with_index | see |
#with_object | see |
Constructor Details
.new ⇒ EratosthenesGenerator
# File 'lib/prime.rb', line 310
def initialize @last_prime_index = -1 super end
Instance Method Details
#next
Alias for #succ.
# File 'lib/prime.rb', line 322
alias next succ
#rewind
[ GitHub ]# File 'lib/prime.rb', line 319
def rewind initialize end
#succ Also known as: #next
[ GitHub ]# File 'lib/prime.rb', line 315
def succ @last_prime_index += 1 EratosthenesSieve.instance.get_nth_prime(@last_prime_index) end