Sha256: f75919c1949e514b6111e4b79ba27547918edcd8389b6ba4f87a459004db2765

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

require 'terminal-table'
require 'pageme'
module DocParser
  # This Output can be used for debugging purposes.

  # This output sends the results directly to the terminal and pipes all rows
  # through a pager
  # @see Output
  class ScreenOutput < Output
    # @!visibility private

    include PageMe

    def initialize
      @tables = []
      @rowcount = 0
    end

    def close
      page do |p|
        p.puts "Showing all #{@tables.length} rows:\n\n"
        @tables.each do |table|
          p.puts table
        end
      end
    end

    def write_row(row)
      raise MissingHeaderException if @header.nil? || @header.length == 0
      out = []
      0.upto(@header.length - 1) do |counter|
        out << [@header[counter], row[counter]]
      end
      @tables << Terminal::Table.new(rows: out)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
docparser-0.1.6 lib/docparser/output/screen_output.rb