Skip to content

Commit

Permalink
add more core definitions relating to numerics
Browse files Browse the repository at this point in the history
  • Loading branch information
haileys committed Dec 12, 2017
1 parent 71c36f7 commit 46835fd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions definitions/core.rb
Expand Up @@ -704,6 +704,8 @@ def zero? => Boolean; end
def nonzero? => Boolean; end
def finite? => Boolean; end
def infinite? => Boolean; end
def negative? => Boolean; end
def positive? => Boolean; end
end

class Integer < Numeric
Expand All @@ -718,6 +720,8 @@ def -(Integer other) => Integer; end
def *(Integer other) => Integer; end

def /(Integer other) => Integer; end

def to_r => Rational; end
end

class Float < Numeric
Expand All @@ -742,6 +746,8 @@ def -(Float other) => Float; end
def *(Float other) => Float; end

def /(Float other) => Float; end

def to_r => Rational; end
end

class String < Object
Expand Down Expand Up @@ -808,6 +814,8 @@ def to_sym => Symbol; end
def intern => Symbol; end

def to_i => Integer; end

def to_r => Rational; end
end

class Array::[ElementType] < Object
Expand Down Expand Up @@ -926,6 +934,8 @@ def to_f => Float; end

def to_h[K, V] => Hash::[K, V]; end

def to_r => Rational; end

def &(:any other) => FalseClass; end

def |(:any other) => Boolean; end
Expand Down Expand Up @@ -957,6 +967,13 @@ class FiberError < StandardError
end

class Rational < Numeric
def to_i => Integer; end
def to_r => Rational; end

def +(Rational other) => Rational; end
def -(Rational other) => Rational; end
def *(Rational other) => Rational; end
def /(Rational other) => Rational; end
end

module ObjectSpace
Expand Down Expand Up @@ -1234,6 +1251,11 @@ class FloatDomainError < RangeError

class Complex < Numeric
I = nil

def to_r => Rational; end

undef negative?
undef positive?
end

class Enumerator::[EnumType] < Object
Expand Down Expand Up @@ -2162,6 +2184,8 @@ def self.now => :instance
def strftime(String format) => String; end

def to_f => Float; end

def to_r => Rational; end
end

module Marshal
Expand Down
2 changes: 2 additions & 0 deletions definitions/lib/bigdecimal.rb
Expand Up @@ -7,4 +7,6 @@ def /(Numeric other) => BigDecimal; end
def *(Numeric other) => BigDecimal; end

def round(Integer n = 0, (Integer|Symbol) mode = 0) => BigDecimal; end

def to_r => Rational; end
end

0 comments on commit 46835fd

Please sign in to comment.