Sha256: 1020d62285a3ef7627db2f31002539bf16f67b9b99aebd914e2f56f06284b02b

Contents?: true

Size: 590 Bytes

Versions: 11

Compression:

Stored size: 590 Bytes

Contents

module Dydx
  module Algebra
    module Operator
      module Parts
        module Interface
          %w(+ - * / ^).map(&:to_sym).each do |operator|
            define_method(operator) do |x|
              x = ::Set::Num.new(x) if x.is_a?(Fixnum)
              if operator == :/ && x.is_0?
                raise ZeroDivisionError
              elsif [:-, :/].include?(operator)
                send(inverse_ope(operator), inverse(x, inverse_ope(operator)))
              else
                super(x)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dydx-0.1.314 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.1.31 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.1.3 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.1.29 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.1.28 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.1.25 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.1.2 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.1.1 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.1.0 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.0.9 lib/dydx/algebra/operator/parts/interface.rb
dydx-0.0.8 lib/dydx/algebra/operator/parts/interface.rb