diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-12-16 13:51:48 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-12-16 13:51:48 +0900 |
| commit | fc5a9c2be250ce2528a3aa76b6885d61e46102de (patch) | |
| tree | 5b84ef05dbeb0f78f3009d08b2c80f9f2adf832c /mrbgems/mruby-complex/mrblib/complex.rb | |
| parent | cc6d17423bb7fae36fbdc20b7773312c94ab8fe5 (diff) | |
| parent | 4bdb1eb5aae8cab47e04f8cb1298a8f220792161 (diff) | |
| download | mruby-fc5a9c2be250ce2528a3aa76b6885d61e46102de.tar.gz mruby-fc5a9c2be250ce2528a3aa76b6885d61e46102de.zip | |
Merge pull request #4877 from shuujii/drop-dependencies-from-mruby-complex-to-some-gems
Drop dependencies from `mruby-complex` to some gems
Diffstat (limited to 'mrbgems/mruby-complex/mrblib/complex.rb')
| -rw-r--r-- | mrbgems/mruby-complex/mrblib/complex.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mrbgems/mruby-complex/mrblib/complex.rb b/mrbgems/mruby-complex/mrblib/complex.rb index f32b84c8b..ea8530919 100644 --- a/mrbgems/mruby-complex/mrblib/complex.rb +++ b/mrbgems/mruby-complex/mrblib/complex.rb @@ -8,7 +8,7 @@ class Complex < Numeric end def to_s - "#{real}#{'+' unless imaginary.negative?}#{imaginary}i" + "#{real}#{'+' unless imaginary < 0}#{imaginary}i" end def +@ @@ -56,7 +56,7 @@ class Complex < Numeric if rhs.is_a? Complex real == rhs.real && imaginary == rhs.imaginary elsif rhs.is_a? Numeric - imaginary.zero? && real == rhs + imaginary == 0 && real == rhs end end @@ -106,14 +106,14 @@ class Complex < Numeric [Fixnum, Float].each do |cls| [:+, :-, :*, :/, :==].each do |op| - cls.instance_exec do + cls.instance_eval do original_operator_name = "__original_operator_#{op}_complex" alias_method original_operator_name, op define_method op do |rhs| if rhs.is_a? Complex - Complex(self).send(op, rhs) + Complex(self).__send__(op, rhs) else - send(original_operator_name, rhs) + __send__(original_operator_name, rhs) end end end |
