Module: MoneyExchange
- Defined in:
- lib/money_exchange.rb,
lib/money_exchange/command.rb,
lib/money_exchange/version.rb
Defined Under Namespace
Classes: Command, Exchange, Money
Constant Summary collapse
- VERSION =
"0.0.3"
Instance Method Summary collapse
-
#method_missing(meth, *a, &b) ⇒ Object
Presume ‘#xxx_to’ style methods as for money exchanges.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *a, &b) ⇒ Object
Presume ‘#xxx_to’ style methods as for money exchanges
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/money_exchange.rb', line 10 def method_missing(meth, *a, &b) case meth when /^([a-z]{3})_to_([a-z]{3})$/ currency, target = $~.captures Money.new(self, currency).send("to_#{target}") when /^([a-z]{3})_to$/ currency, targets = $~[1], a targets.map { |t| Money.new(self, currency).send("to_#{t}") } else super end end |