Skip to content
Permalink
Browse files

Merge pull request #634 from kachick/some-integer-methods

Implement some Integer methods, and port to .py
  • Loading branch information
alex committed Apr 19, 2013
2 parents 8bd0c53 + e4b88b7 commit a1ef605730c4f205a89c161ee32c0db442a6de85
@@ -18,32 +18,12 @@ def times(&block)
self
end

def integer?
return true
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

def pred
return self - 1
end
end

This file was deleted.

This file was deleted.

@@ -6,5 +6,19 @@ class W_IntegerObject(W_NumericObject):
classdef = ClassDef("Integer", W_NumericObject.classdef, filepath=__file__)

@classdef.method("to_i")
@classdef.method("to_int")
@classdef.method("ceil")
@classdef.method("floor")
@classdef.method("truncate")
@classdef.method("ord")
@classdef.method("numerator")
def method_to_i(self, space):
return self

@classdef.method("integer?")
def method_integerp(self, space):
return space.w_true

@classdef.method("denominator")
def method_denominator(self, space):
return space.newint(1)

0 comments on commit a1ef605

Please sign in to comment.