Sha256: 3e3e14ee8e7fa38a1253277249368188a7b47084b106273466585f93b35678eb
Contents?: true
Size: 717 Bytes
Versions: 8
Compression:
Stored size: 717 Bytes
Contents
module Alf class Renderer # # Implements Alf::Renderer contract for outputting CSV files. # class CSV < Renderer include Support::CSVUtils def self.mime_type "text/csv" end def each(&bl) return to_enum unless block_given? with_csv(ProcIO.new(bl), options.merge(row_sep: "\n")) do |csv| header = nil each_tuple do |tuple| unless header header = tuple.keys csv << header.map(&:to_s) end csv << header.map{|k| tuple[k]} end end end Alf::Renderer.register(:csv, "in CSV", self) end # class CSV end # class Renderer end # module Alf
Version data entries
8 entries across 8 versions & 1 rubygems