Sha256: 005b103a54680262f1b7bec8499b0625ccbf49edea2668846319c6b98f155929

Contents?: true

Size: 675 Bytes

Versions: 2

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

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

2 entries across 2 versions & 1 rubygems

Version Path
danica-2.7.7 lib/danica/base_operations.rb
danica-2.7.6 lib/danica/base_operations.rb