Module: Monee::Comparison

Includes:
Comparable
Included in:
Money
Defined in:
lib/monee/comparison.rb

Overview

modularizing the comparison of money objects method in a separate module

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Boolean

this is the spaceship operator overriding, this will take care of >, <, ==

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'lib/monee/comparison.rb', line 10

def <=>(other)
  if currency == other.currency
    cents <=> other.cents
  else
    cents <=> other.convert_to_cents(currency)
  end
end