lib/dydx/algebra/operator/parts/num.rb in dydx-0.0.4 vs lib/dydx/algebra/operator/parts/num.rb in dydx-0.0.5
- old
+ new
@@ -6,37 +6,25 @@
def +(x)
if n == 0
x
elsif x.is_a?(Num)
_(n + x.n)
+ elsif x.subtrahend? && x.x.is_a?(Num)
+ _(n - x.x.n)
else
super(x)
end
end
- def -(x)
- if x.is_a?(Num)
- _(n - x.n)
- else
- super(x)
- end
- end
-
def *(x)
if n == 0
self
elsif n == 1
x
elsif x.is_a?(Num)
_(n * x.n)
- else
- super(x)
- end
- end
-
- def /(x)
- if (n == 0)
- self
+ elsif x.divisor? && x.x.is_a?(Num)
+ _(n / x.x.n)
else
super(x)
end
end