Sha256: b1c35c92e9f3bb1636f2a4f5e51656b61b527a55e48ae5614dbec39c0e1977f9

Contents?: true

Size: 767 Bytes

Versions: 5

Compression:

Stored size: 767 Bytes

Contents

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

  # It 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

5 entries across 5 versions & 1 rubygems

Version Path
docparser-0.1.4 lib/docparser/output/screen_output.rb
docparser-0.1.3 lib/docparser/output/screen_output.rb
docparser-0.1.2 lib/docparser/output/screen_output.rb
docparser-0.1.1 lib/docparser/output/screen_output.rb
docparser-0.1.0 lib/docparser/output/screen_output.rb