Sha256: d92f20a3d70844e1a60cd9c23343b5ec88e068a899aa60d2ad64191373ec1317

Contents?: true

Size: 501 Bytes

Versions: 1

Compression:

Stored size: 501 Bytes

Contents

require 'tty/table'

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

      # defer creating table until we get first result and can determine headers
      def first_load(result)
        headers = result.keys
        @table = TTY::Table.new(header: headers)
      end

      def load(result)
        @table << result
      end

      def finish
        puts @table.render(:ascii)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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