class Csv2hash::Adapter::CsvAdapter

Attributes

file_path[RW]

Public Class Methods

new(file_path) click to toggle source
# File lib/csv2hash/adapters/csv_adapter.rb, line 11
def initialize file_path
  self.file_path = file_path
end

Public Instance Methods

source() click to toggle source
# File lib/csv2hash/adapters/csv_adapter.rb, line 15
def source
  check_file!
  CSV.read self.file_path
end

Private Instance Methods

check_file!() click to toggle source
# File lib/csv2hash/adapters/csv_adapter.rb, line 22
def check_file!
  raise ::Csv2hash::InvalidFile unless File.extname(self.file_path) =~ /csv/i
end