Class: Prime::EratosthenesGenerator
- Inherits:
-
PseudoPrimeGenerator
- Object
- PseudoPrimeGenerator
- Prime::EratosthenesGenerator
- Defined in:
- lib/vendor/backports-3.3.5/lib/backports/1.9.1/stdlib/prime.rb
Overview
An implementation of PseudoPrimeGenerator
.
Uses EratosthenesSieve
.
Instance Method Summary collapse
-
#initialize ⇒ EratosthenesGenerator
constructor
A new instance of EratosthenesGenerator.
- #rewind ⇒ Object
- #succ ⇒ Object (also: #next)
Methods inherited from PseudoPrimeGenerator
#each, #upper_bound, #upper_bound=, #with_object
Methods included from Enumerable
#chunk, #count, #cycle, #drop, #drop_while, #each_entry, #each_with_index_with_optional_args_and_block, #each_with_object, #entries_with_optional_arguments, #find_index, #first, #flat_map, #group_by, #inject_with_symbol, #lazy, #max_by, #min_by, #minmax, #minmax_by, #none?, #one?, #reverse_each, #slice_before, #sum, #take, #take_while, #to_a_with_optional_arguments
Constructor Details
#initialize ⇒ EratosthenesGenerator
Returns a new instance of EratosthenesGenerator.
292 293 294 295 |
# File 'lib/vendor/backports-3.3.5/lib/backports/1.9.1/stdlib/prime.rb', line 292 def initialize @last_prime = nil super end |
Instance Method Details
#rewind ⇒ Object
300 301 302 |
# File 'lib/vendor/backports-3.3.5/lib/backports/1.9.1/stdlib/prime.rb', line 300 def rewind initialize end |
#succ ⇒ Object Also known as: next
297 298 299 |
# File 'lib/vendor/backports-3.3.5/lib/backports/1.9.1/stdlib/prime.rb', line 297 def succ @last_prime = @last_prime ? EratosthenesSieve.instance.next_to(@last_prime) : 2 end |