Skip to content
Permalink
Browse files

a bunch of trivial integer methods

  • Loading branch information
Alex Gaynor
Alex Gaynor committed Apr 4, 2013
1 parent eee3dbe commit 4aff3279445d7a2ca2ce168756ea1e8dcf97bc00
@@ -7,7 +7,8 @@ def succ
self + 1
end

def upto(n)
def upto(n, &block)
return self.enum_for(:upto) if !block
i = self
while i <= n
yield i
@@ -1,6 +1,6 @@
class Integer < Numeric
def downto(limit, &block)
raise NotImplementedError.new("Object#enum_for") if !block
return self.enum_for(:downto) unless block
current = self
while current >= limit
yield current
@@ -17,4 +17,29 @@ def times(&block)
end
self
end

def ceil
return self
end

def floor
return self
end

def truncate
return self
end

def denominator
return 1
end

def numerator
return self
end

def next
return self + 1
end
alias succ next
end

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 4aff327

Please sign in to comment.
You can’t perform that action at this time.