Module: Monefy::Matchers

Included in:
Monefy
Defined in:
lib/monefy/matchers.rb

Overview

Encapsulate all the logic to compare differente Monefy instances

Instance Method Summary collapse

Instance Method Details

#!=(monefy) ⇒ Boolean

Check if two distinct Monefy instances are different.

are equal.

Examples:

Monefy.new(50, 'EUR') != Monefy.new(40, 'EUR') # => true
Monefy.new(50, 'EUR') != Monefy.new(55.5, 'USD') # => false

Parameters:

  • monefy (Monefy)

    another Monefy instance.

Returns:

  • (Boolean)

    true if both instances are different and false if they



31
32
33
34
35
# File 'lib/monefy/matchers.rb', line 31

def != monefy
  validate_monefy_instance(monefy)

  amount != converted_money_currency(monefy)
end

#<(monefy) ⇒ Boolean

Check if one Monefy instance is less than another.

false if not.

Examples:

Monefy.new(50, 'EUR') < Monefy.new(40, 'EUR') # => false
Monefy.new(50, 'EUR') < Monefy.new(200, 'USD') # => true

Parameters:

  • monefy (Monefy)

    another Monefy instance.

Returns:

  • (Boolean)

    true if current instace is less than another and



63
64
65
66
67
# File 'lib/monefy/matchers.rb', line 63

def < monefy
  validate_monefy_instance(monefy)

  amount < converted_money_currency(monefy)
end

#==(monefy) ⇒ Boolean

Check if two distinct Monefy instances are equal.

are different.

Examples:

Monefy.new(50, 'EUR') == Monefy.new(40, 'EUR') # => false
Monefy.new(50, 'EUR') == Monefy.new(55.5, 'USD') # => true

Parameters:

  • monefy (Monefy)

    another Monefy instance.

Returns:

  • (Boolean)

    true if both instances are equal and false if they



15
16
17
18
19
# File 'lib/monefy/matchers.rb', line 15

def == monefy
  validate_monefy_instance(monefy)

  amount == converted_money_currency(monefy)
end

#>(monefy) ⇒ Boolean

Check if one Monefy instance is greater than another.

false if not.

Examples:

Monefy.new(50, 'EUR') > Monefy.new(40, 'EUR') # => true
Monefy.new(50, 'EUR') > Monefy.new(200, 'USD') # => false

Parameters:

  • monefy (Monefy)

    another Monefy instance.

Returns:

  • (Boolean)

    true if current instace is greater than another and



47
48
49
50
51
# File 'lib/monefy/matchers.rb', line 47

def > monefy
  validate_monefy_instance(monefy)

  amount > converted_money_currency(monefy)
end