mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #4448 from shuujii/move-Object-Rational-Complex-to-Kernel
Move `Object#(Rational|Complex)` to `Kernel`
This commit is contained in:
@@ -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
|
||||
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|
|
||||
|
||||
Reference in New Issue
Block a user