Sha256: cd43a7c2f927beedb5fb16b01df33d0e48564c3e6a8e11238829ef1008318d0d

Contents?: true

Size: 590 Bytes

Versions: 3

Compression:

Stored size: 590 Bytes

Contents

module Csv2hash
  module Adapter
    class Base

      class UnsupportedAdapter < StandardError ; end

      def self.create adapter_name, file_path_or_data
        # binding.pry
        load "csv2hash/adapters/#{adapter_name}_adapter.rb"
        class_eval("Csv2hash::Adapter::#{klass_adapter(adapter_name)}").new file_path_or_data
      end

      private

      def self.klass_adapter adapter_symbol
        case adapter_symbol
        when :memory then :MemoryAdapter
        when :csv then :CsvAdapter
        else raise UnsupportedAdapter.new
        end
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
csv2hash-0.5.0 lib/csv2hash/adapters/base.rb
csv2hash-0.4.0 lib/csv2hash/adapters/base.rb
csv2hash-0.3.0 lib/csv2hash/adapters/base.rb