module Trader::ConverterConfigurator
Public Instance Methods
from_yaml(_yaml)
click to toggle source
# File lib/trade-o-matic/support/converter_configurator.rb, line 5 def from_yaml(_yaml) _yaml.each do |conv| type = conv['type'] || detect_type(conv) converter = send "configure_yaml_#{type}", conv Currency.register_conversion conv['from'], conv['to'], converter, inverse: !!conv['inverse'] Currency.register_conversion conv['to'], conv['from'], converter, inverse: !conv['inverse'] if conv['symetric'] end end
Private Instance Methods
configure_yaml_fixed(_params)
click to toggle source
# File lib/trade-o-matic/support/converter_configurator.rb, line 17 def configure_yaml_fixed(_params) FixedConverter.new _params['rate'] end
configure_yaml_json_api(_params)
click to toggle source
# File lib/trade-o-matic/support/converter_configurator.rb, line 21 def configure_yaml_json_api(_params) require 'trade-o-matic/converters/json_api_converter' JsonApiConverter.new(_params['url'], _params['path'].split('.'), _params['ttl'] || 30) end
configure_yaml_web(_params)
click to toggle source
# File lib/trade-o-matic/support/converter_configurator.rb, line 26 def configure_yaml_web(_params) require 'trade-o-matic/converters/web_converter' WebConverter.new(_params['url'], _params['path'], _params['ttl'] || 30) end
detect_type(_params)
click to toggle source
# File lib/trade-o-matic/support/converter_configurator.rb, line 35 def detect_type(_params) return 'json_api' if _params['url'] return 'fixed' end
invert(_converter)
click to toggle source
# File lib/trade-o-matic/support/converter_configurator.rb, line 31 def invert(_converter) InverseConverter.new _converter end