Top Level Namespace

Defined Under Namespace

Modules: CSVHash

Instance Method Summary collapse

Instance Method Details

#CSVHash(arg, columns = nil) ⇒ Object

Pass either a path to a csv file to parse which will return an array of hashes (stringified keys) or pass an array of hashes and an array of column names See readme.rdoc for more detaild information



72
73
74
75
76
77
78
79
80
# File 'lib/csv-hash.rb', line 72

def CSVHash arg, columns=nil
  if arg.is_a?(File)
    CSVHash.from_file(arg.path)
  elsif arg.is_a?(String)
    CSVHash.from_file(arg)
  elsif arg.is_a?(Array) && columns.is_a?(Array)
    CSVHash.to_string(arg,columns)
  end
end