Sha256: 0615232cc060a90402e85736e0ba6ec36f0513f27382b1e5f162262e3813b1a0

Contents?: true

Size: 449 Bytes

Versions: 1

Compression:

Stored size: 449 Bytes

Contents

require_relative 'abstract'

require 'csv'

module Csv2hash
  module Adapter
    class CsvAdapter < Abstract

      attr_accessor :file_path

      def initialize file_path
        self.file_path = file_path
      end

      def source
        check_file!
        CSV.read self.file_path
      end

      private

      def check_file!
        raise ::Csv2hash::InvalidFile unless File.extname(self.file_path) =~ /csv/i
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
csv2hash-0.7.7 lib/csv2hash/adapters/csv_adapter.rb