Commit 6c9c189e authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Move `Object#(Rational|Complex)` to `Kernel`

parent 89d29264
...@@ -147,8 +147,10 @@ class << Complex ...@@ -147,8 +147,10 @@ class << Complex
alias_method :rect, :rectangular alias_method :rect, :rectangular
end end
def Complex(real, imaginary = 0) module Kernel
def Complex(real, imaginary = 0)
Complex.rectangular(real, imaginary) Complex.rectangular(real, imaginary)
end
end end
[Fixnum, Float].each do |cls| [Fixnum, Float].each do |cls|
......
...@@ -75,11 +75,13 @@ class Numeric ...@@ -75,11 +75,13 @@ class Numeric
end end
end end
def Rational(numerator = 0, denominator = 1) module Kernel
def Rational(numerator = 0, denominator = 1)
a = numerator a = numerator
b = denominator b = denominator
a, b = b, a % b until b == 0 a, b = b, a % b until b == 0
Rational._new(numerator.div(a), denominator.div(a)) Rational._new(numerator.div(a), denominator.div(a))
end
end end
[:+, :-, :*, :/, :<=>, :==, :<, :<=, :>, :>=].each do |op| [:+, :-, :*, :/, :<=>, :==, :<, :<=, :>, :>=].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