Sha256: 0415bf5dd713c9725c4a2ded0e7d32b00aae53802143a2c2fe2cd64d5e06c9c5
Contents?: true
Size: 669 Bytes
Versions: 3
Compression:
Stored size: 669 Bytes
Contents
# frozen_string_literal: true require 'csv' module SoapyBing class Ads module Parsers class BulkCsvParser def initialize(raw) @raw = raw end def rows @rows ||= begin header, *body = extract_csv_payload body.map { |row| header.zip(row).to_h } end end private attr_reader :raw def extract_csv_payload text = raw.dup text.force_encoding(Encoding::UTF_8).encode! unless text.encoding == Encoding::UTF_8 text.sub!(/^\xEF\xBB\xBF/, '') # cleanup BOM CSV.parse(text) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems