module Money::Exchange

Direct including types

Defined in:

money/money/exchange.cr

Instance Method Summary

Instance Method Detail

def exchange_to(other_currency : String | Symbol | Currency) : Money #

Exchanges self to a new Money object in other_currency.

Money.default_exchange.rate_store["USD", "EUR"] = 1.23
Money.default_exchange.rate_store["EUR", "USD"] = 0.82

Money.new(1_00, "USD").exchange_to("EUR") # => Money(@amount=1.23, @currency="EUR")
Money.new(1_00, "EUR").exchange_to("USD") # => Money(@amount=0.82, @currency="USD")

[View source]
def with_same_currency(other : Money, &) #

Yields other Money object exchanged to self.currency.


[View source]