class Money::Currency
Public Class Methods
[](currency)
click to toggle source
# File lib/money/currency.rb, line 10 def self.[](currency) return currency if currency.kind_of?(self) Currency.new(currency) end
exchange(&block)
click to toggle source
# File lib/money/currency.rb, line 6 def self.exchange(&block) @@exchange_handler = block end
Public Instance Methods
to(other_currency, on:)
click to toggle source
# File lib/money/currency.rb, line 15 def to(other_currency, on:) other_currency = Currency[other_currency] return Money.new(1.0, self, on) if self == other_currency Money.new(call_exchange_handler(other_currency, on), other_currency, on) end
to_s()
click to toggle source
# File lib/money/currency.rb, line 21 def to_s id end
Protected Instance Methods
call_exchange_handler(other_currency, date)
click to toggle source
# File lib/money/currency.rb, line 27 def call_exchange_handler(other_currency, date) @@exchange_handler.call(id, other_currency.id, date) end