aboutsummaryrefslogtreecommitdiffstats
path: root/lib/prime.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prime.rb')
-rw-r--r--lib/prime.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/prime.rb b/lib/prime.rb
index 1eed28d914..c9575f6a2a 100644
--- a/lib/prime.rb
+++ b/lib/prime.rb
@@ -270,7 +270,7 @@ class Prime
# see +Enumerator+#with_index.
def with_index(offset = 0)
- return enum_for(:with_index, offset) unless block_given?
+ return enum_for(:with_index, offset) { Float::INFINITY } unless block_given?
return each_with_index(&proc) if offset == 0
each do |prime|
@@ -281,11 +281,15 @@ class Prime
# see +Enumerator+#with_object.
def with_object(obj)
- return enum_for(:with_object, obj) unless block_given?
+ return enum_for(:with_object, obj) { Float::INFINITY } unless block_given?
each do |prime|
yield prime, obj
end
end
+
+ def size
+ Float::INFINITY
+ end
end
# An implementation of +PseudoPrimeGenerator+.