Unverified Commit 1cdb3ec9 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4448 from shuujii/move-Object-Rational-Complex-to-Kernel

Move `Object#(Rational|Complex)` to `Kernel`
parents ed70e812 6c9c189e
......@@ -107,7 +107,7 @@ class Complex < Numeric
def polar
[abs, arg]
end
def real?
false
end
......@@ -147,8 +147,10 @@ class << Complex
alias_method :rect, :rectangular
end
def Complex(real, imaginary = 0)
Complex.rectangular(real, imaginary)
module Kernel
def Complex(real, imaginary = 0)
Complex.rectangular(real, imaginary)
end
end
[Fixnum, Float].each do |cls|
......@@ -165,4 +167,4 @@ end
end
end
end
end
\ No newline at end of file
end
......@@ -75,11 +75,13 @@ class Numeric
end
end
def Rational(numerator = 0, denominator = 1)
a = numerator
b = denominator
a, b = b, a % b until b == 0
Rational._new(numerator.div(a), denominator.div(a))
module Kernel
def Rational(numerator = 0, denominator = 1)
a = numerator
b = denominator
a, b = b, a % b until b == 0
Rational._new(numerator.div(a), denominator.div(a))
end
end
[:+, :-, :*, :/, :<=>, :==, :<, :<=, :>, :>=].each do |op|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment