Sha256: fbcf55576a5d0ecef8950a19e00f512de8ed323a6568d1b5b1e4c8de9a60f4c6

Contents?: true

Size: 491 Bytes

Versions: 1

Compression:

Stored size: 491 Bytes

Contents

require 'tty/table'

module Chronicle
  module ETL
    class TableLoader < Chronicle::ETL::Loader
      def initialize(options)
        super(options)
      end

      def load(record)
        record_hash = record.to_h_flattened
        @table ||= TTY::Table.new(header: record_hash.keys)
        values = record_hash.values.map{|x| x.to_s[0..30]}
        @table << values
      end

      def finish
        puts @table.render(:ascii, padding: [0, 1]) if @table
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chronicle-etl-0.2.4 lib/chronicle/etl/loaders/table_loader.rb