Sha256: 6e7ab43496c4c35d747492c45749d8112350b27ec3617cd1a4471bf3251ef119
Contents?: true
Size: 567 Bytes
Versions: 1
Compression:
Stored size: 567 Bytes
Contents
module SeedGimmick module SeedIO class CsvFile < Base def self.raw_data(array_of_hashes) columns = array_of_hashes.first.keys array_of_hashes.map(&:values).unshift(columns).map(&:to_csv).join end def load_data data = CSV.read(seed_file, headers: :first_row).map(&:to_hash) || (raise LoadFailed.new(seed_file)) set_data(data) self end def dump_data(array_of_hashes) write_raw(self.class.raw_data(array_of_hashes)) array_of_hashes.size end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
seed_gimmick-0.0.3 | lib/seed_gimmick/seed_io/csv_file.rb |