Sha256: 62f5c0587660f42f677a6c64b3301589cbb8ad4b5bb981dde06951789273c9fa

Contents?: true

Size: 427 Bytes

Versions: 4

Compression:

Stored size: 427 Bytes

Contents

require 'tty/table'

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chronicle-etl-0.2.3 lib/chronicle/etl/loaders/table_loader.rb
chronicle-etl-0.2.2 lib/chronicle/etl/loaders/table_loader.rb
chronicle-etl-0.2.1 lib/chronicle/etl/loaders/table_loader.rb
chronicle-etl-0.2.0 lib/chronicle/etl/loaders/table_loader.rb