Class: YDIM::MobileCurrencyConverter
- Inherits:
-
Object
- Object
- YDIM::MobileCurrencyConverter
- Defined in:
- lib/ydim/currency_converter.rb
Direct Known Subclasses
Instance Method Summary collapse
- #convert(amount, origin, target) ⇒ Object
-
#initialize(conversions = {}) ⇒ MobileCurrencyConverter
constructor
A new instance of MobileCurrencyConverter.
Constructor Details
#initialize(conversions = {}) ⇒ MobileCurrencyConverter
Returns a new instance of MobileCurrencyConverter.
6 7 8 |
# File 'lib/ydim/currency_converter.rb', line 6 def initialize(conversions={}) @conversions = conversions end |
Instance Method Details
#convert(amount, origin, target) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/ydim/currency_converter.rb', line 9 def convert(amount, origin, target) return amount if(origin == target) amount.to_f * @conversions.fetch([origin, target]) { raise "Unknown Conversion '#{origin}' -> '#{target}'" } end |