Module: Prime::OldCompatibility

Defined in:
lib/prime.rb

Overview

Provides a Prime object with compatibility to Ruby 1.8 when instanciated via Prime.new.

Instance Method Summary (collapse)

Instance Method Details

- (Object) each

Overwrites Prime#each.

Iterates the given block over all prime numbers. Note that enumeration starts from the current position of internal pointer, not rewound.



457
458
459
460
461
462
# File 'lib/prime.rb', line 457

def each
  return @generator.dup unless block_given?
  loop do
	yield succ
  end
end

- (Object) succ Also known as: next

Returns the next prime number and forwards internal pointer.



448
449
450
# File 'lib/prime.rb', line 448

def succ
  @generator.succ
end