module Monee::Arithmetic
modularizing the arithmetic related methods in a separate module for money
Public Instance Methods
choose_operand(operator, operand)
click to toggle source
convert to cents if add or subtract dont convert to cents if multiply or divide
@params operator [+, -, *, /] @return [Numeric]
# File lib/monee/arithmetic.rb, line 32 def choose_operand(operator, operand) if %i[+ -].include?(operator) operand.to_cents elsif %i[* /].include?(operator) operand end end
coerce(other)
click to toggle source
this method is to support the order of the operation 2 * Monee::Money.new
(50, 'EUR')
# File lib/monee/arithmetic.rb, line 42 def coerce(other) return self, other end