Class: CoinSync::Config::CurrencyConversionOptions
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- CoinSync::Config::CurrencyConversionOptions
- Defined in:
- lib/coinsync/config.rb
Constant Summary collapse
- DEFAULT_CURRENCY_CONVERTER =
:exchangeratesapi
Instance Method Summary collapse
- #currency_converter ⇒ Object
-
#initialize(options) ⇒ CurrencyConversionOptions
constructor
A new instance of CurrencyConversionOptions.
Constructor Details
#initialize(options) ⇒ CurrencyConversionOptions
Returns a new instance of CurrencyConversionOptions.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/coinsync/config.rb', line 96 def initialize() super if ['using'] self.currency_converter_name = ['using'].to_sym else self.currency_converter_name = DEFAULT_CURRENCY_CONVERTER end if ['to'] self.currency = FiatCurrency.new(['to'].upcase) else raise "'convert_currency' requires a 'to' field with a currency code" end end |
Instance Method Details
#currency_converter ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'lib/coinsync/config.rb', line 112 def currency_converter currency_converter_class = CurrencyConverters.registered[currency_converter_name] if currency_converter_class currency_converter_class.new(self) else raise "Unknown currency converter: #{currency_converter_name}" end end |