class CoinSync::Source
Attributes
filename[R]
key[R]
params[R]
Public Class Methods
new(config, key)
click to toggle source
# File lib/coinsync/source.rb, line 7 def initialize(config, key) @config = config @key = key definition = config.source_definitions[key] if definition.is_a?(Hash) @params = definition @filename = definition['file'] type = (definition['type'] || key).to_sym elsif definition.is_a?(String) @params = {} @filename = definition type = key.to_sym elsif !config.source_definitions.has_key?(key) raise "No such key in source list: '#{key}'" else raise "Unexpected source definition for '#{key}': #{definition}" end @importer_class = Importers.registered[type] if @importer_class.nil? if @params['type'] raise "Unknown source type for '#{key}': #{params['type']}" else raise "Unknown source type for '#{key}': please include a 'type' parameter " + "or use a name of an existing importer" end end end
Public Instance Methods
importer()
click to toggle source
# File lib/coinsync/source.rb, line 39 def importer @importer ||= @importer_class.new(@config, @params) end