Sha256: b606da14aff9256b3e525f76d8848888b9b8ee8f28131442241de9cc47491b5f

Contents?: true

Size: 574 Bytes

Versions: 5

Compression:

Stored size: 574 Bytes

Contents

module Tableview::Output
  class ASCII
    require 'terminal-table/import'
    def process(tv)
      @table = ""
      tv.subtables.each do |sub|
        @table << "# #{sub.title}" unless sub.title.blank?
        @table << table { |t|
          sub.parts.each do |part|
            part.rows.each do |row|
              t.add_row row.cells.map {|cell| {:value => cell.contents}.merge(cell.options) }
            end
            t.add_separator unless part == sub.parts.last
          end
        }.to_s
      end
    end
    
    def to_s
      @table
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tableview-0.4.0 lib/tableview/output/ascii.rb
tableview-0.3.3 lib/tableview/output/ascii.rb
tableview-0.3.2 lib/tableview/output/ascii.rb
tableview-0.3.1 lib/tableview/output/ascii.rb
tableview-0.3.0 lib/tableview/output/ascii.rb