Sha256: 2a14a4ce56a02fab949bd30781d332706afe40b1958b2a37e1e96b07625df6bc

Contents?: true

Size: 568 Bytes

Versions: 16

Compression:

Stored size: 568 Bytes

Contents

module Csv2hash
  module Adapter
    class Base

      class UnsupportedAdapter < StandardError ; end

      def self.create adapter_name, file_path_or_data
        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

16 entries across 16 versions & 1 rubygems

Version Path
csv2hash-0.7.7 lib/csv2hash/adapters/base.rb
csv2hash-0.7.6 lib/csv2hash/adapters/base.rb
csv2hash-0.7.5 lib/csv2hash/adapters/base.rb
csv2hash-0.7.3 lib/csv2hash/adapters/base.rb
csv2hash-0.7.2 lib/csv2hash/adapters/base.rb
csv2hash-0.7.1 lib/csv2hash/adapters/base.rb
csv2hash-0.7.0 lib/csv2hash/adapters/base.rb
csv2hash-0.6.8 lib/csv2hash/adapters/base.rb
csv2hash-0.6.7 lib/csv2hash/adapters/base.rb
csv2hash-0.6.6 lib/csv2hash/adapters/base.rb
csv2hash-0.6.5 lib/csv2hash/adapters/base.rb
csv2hash-0.6.4 lib/csv2hash/adapters/base.rb
csv2hash-0.6.3 lib/csv2hash/adapters/base.rb
csv2hash-0.6.2 lib/csv2hash/adapters/base.rb
csv2hash-0.6.1 lib/csv2hash/adapters/base.rb
csv2hash-0.6.0 lib/csv2hash/adapters/base.rb