lib/dydx/helper.rb in dydx-0.1.29 vs lib/dydx/helper.rb in dydx-0.1.31

- old
+ new

@@ -20,24 +20,16 @@ :/ => :*, :^ => :|, :| => :^ } - def super_ope(operator) - SUPER_OPE_RELATION[operator] - end - - def sub_ope(operator) - SUPER_OPE_RELATION.invert[operator] - end - def inverse_ope(operator) INVERSE_OPE_RELATION[operator] end def inverse_super_ope(operator) - inverse_ope(super_ope(operator)) + inverse_ope(operator.super) end def is_num? (is_a?(Num) || is_a?(Fixnum) || is_a?(Float)) || (is_a?(Inverse) && x.is_num?) end @@ -53,11 +45,11 @@ def is_minus1? [1, -1.0].include?(self)|| (is_a?(Num) && n.is_minus1?) end def distributive?(ope1, ope2) - [super_ope(ope1), inverse_super_ope(ope1)].include?(ope2) + [ope1.super, ope1.inverse_super].include?(ope2) end def combinable?(x, operator) case operator when :+ @@ -129,9 +121,21 @@ end Symbol.class_eval do def commutative? [:+, :*].include?(self) + end + + def super + SUPER_OPE_RELATION[self] || self + end + + def sub + SUPER_OPE_RELATION.invert[self] || self + end + + def inverse_super + inverse_super_ope(self) || self end end def ==(x) to_s == x.to_s