Class: Prime::EratosthenesGenerator (Ruby 2.2.2)
Description: Class : Prime::EratosthenesGenerator - Ruby 2.2.2

- Home
- Core 2.2.2
- Std-lib 2.2.2
- Downloads

Support for the Ruby 2.2 series has ended. See here for reference.

### Home Classes Methods

### In Files

- prime.rb

### Parent

Prime::PseudoPrimeGenerator

### Methods

- ::new
- #next
- #rewind
- #succ

### Class/Module Index

Quicksearch

- Integer
- Prime
- Prime::EratosthenesGenerator
- Prime::EratosthenesSieve
- Prime::Generator23
- Prime::OldCompatibility
- Prime::PseudoPrimeGenerator
- Prime::TrialDivision
- Prime::TrialDivisionGenerator

No matching classes.

# Prime::EratosthenesGenerator

An implementation of `PseudoPrimeGenerator`.

Uses `EratosthenesSieve`.

### Public Class Methods

new() click to toggle source

                   # File prime.rb, line 307
    def initialize
      @last_prime_index = -1
      super
    end

### Public Instance Methods

next() click to toggle source
Alias for: succ
rewind() click to toggle source

                   # File prime.rb, line 316
    def rewind
      initialize
    end

succ() click to toggle source

                   # File prime.rb, line 312
    def succ
      @last_prime_index += 1
      EratosthenesSieve.instance.get_nth_prime(@last_prime_index)
    end

Also aliased as: next