Sha256: 836af3a31d3396913ba10df34a410ee659c2b567b41e7d58f36c4da428c7b3d4

Contents?: true

Size: 643 Bytes

Versions: 3

Compression:

Stored size: 643 Bytes

Contents

module Danica
  module BaseOperations
    def +(other)
      formatted_operation other, addition(self, other)
    end

    def *(other)
      formatted_operation other, multiplication(self, other)
    end

    def /(other)
      formatted_operation other, division(self, other)
    end

    def -(other)
      formatted_operation other, (self + negative(other))
    end

    def **(other)
      formatted_operation other, power(self, other)
    end

    def -@
      negative(self)
    end

    private

    def formatted_operation(other, value)
      return other.repack(value) if other.is_a?(Danica::Formatted)
      value
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danica-2.7.4 lib/danica/base_operations.rb
danica-2.7.3 lib/danica/base_operations.rb
danica-2.7.2 lib/danica/base_operations.rb