Sha256: 5ec9474489d36019a4ee3c163f206de5e52b19f3f464a26c1c0cc13a1d6c027f

Contents?: true

Size: 648 Bytes

Versions: 4

Compression:

Stored size: 648 Bytes

Contents

module Dydx
  module Algebra
    module Operator
      module Parts
        module Base
          %w(+ - * / ^).each do |operator|
            define_method(operator) do |x|
              if self == x && operator != '^'
                case operator
                when '+'
                  _(2) * self
                when '-'
                  _(0)
                when '*'
                  self ^ _(2)
                when '/'
                  _(1)
                end
              else
                ::Algebra::Formula.new(self, x, operator.to_sym)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dydx-0.0.4 lib/dydx/algebra/operator/parts/base.rb
dydx-0.0.3 lib/dydx/algebra/operator/parts/base.rb
dydx-0.0.2 lib/dydx/algebra/operator/parts/base.rb
dydx-0.0.1 lib/dydx/algebra/operator/parts/base.rb