diff options
| author | KOBAYASHI Shuji <[email protected]> | 2019-12-15 22:51:07 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2019-12-15 22:51:07 +0900 |
| commit | 4bdb1eb5aae8cab47e04f8cb1298a8f220792161 (patch) | |
| tree | 4a3ef3bbbd92f26627c72a9916564a79cfebd0a3 /mrbgems/mruby-complex | |
| parent | 6c5ee8f79e430354fe7e569553bda2d6f79b7aee (diff) | |
| download | mruby-4bdb1eb5aae8cab47e04f8cb1298a8f220792161.tar.gz mruby-4bdb1eb5aae8cab47e04f8cb1298a8f220792161.zip | |
Drop dependencies from `mruby-complex` to some gems
Diffstat (limited to 'mrbgems/mruby-complex')
| -rw-r--r-- | mrbgems/mruby-complex/mrbgem.rake | 3 | ||||
| -rw-r--r-- | mrbgems/mruby-complex/mrblib/complex.rb | 10 |
2 files changed, 5 insertions, 8 deletions
diff --git a/mrbgems/mruby-complex/mrbgem.rake b/mrbgems/mruby-complex/mrbgem.rake index 19612e74d..8f782ae18 100644 --- a/mrbgems/mruby-complex/mrbgem.rake +++ b/mrbgems/mruby-complex/mrbgem.rake @@ -3,8 +3,5 @@ MRuby::Gem::Specification.new('mruby-complex') do |spec| spec.author = 'mruby developers' spec.summary = 'Complex class' - spec.add_dependency 'mruby-metaprog', core: 'mruby-metaprog' - spec.add_dependency 'mruby-object-ext', core: 'mruby-object-ext' - spec.add_dependency 'mruby-numeric-ext', core: 'mruby-numeric-ext' spec.add_dependency 'mruby-math', core: 'mruby-math' end 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 |
