Class: Lipwa::Money
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Lipwa::Money
- Defined in:
- lib/lipwa/money.rb
Overview
Immutable representation of an amount in minor currency units. KES has no subunit in practice, but we keep minor units as the storage form so other currencies fit the same shape later.
Instance Method Summary collapse
Instance Method Details
#+(other) ⇒ Object
14 15 16 17 |
# File 'lib/lipwa/money.rb', line 14 def +(other) assert_same_currency!(other) self.class.new(amount: amount + other.amount, currency: currency) end |
#-(other) ⇒ Object
19 20 21 22 |
# File 'lib/lipwa/money.rb', line 19 def -(other) assert_same_currency!(other) self.class.new(amount: amount - other.amount, currency: currency) end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/lipwa/money.rb', line 24 def to_s "#{amount} #{currency}" end |