Class: Cc::Api::Presentor::Tabler

Inherits:
Object
  • Object
show all
Includes:
CommandLineReporter
Defined in:
lib/cc/api/presentor/presentor.rb

Instance Method Summary collapse

Instance Method Details

#present(result, column_width, column_padding, offset, limit) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cc/api/presentor/presentor.rb', line 10

def present result, column_width, column_padding, offset, limit
  unless result.empty?
    table :border => true do
      row do
        result.first.collect{|k,v| k}.each do |col|
          column(col, align: 'left', width: column_width || 30, padding: column_padding || 5)
        end
      end

      result.drop(offset || 0).each_with_index do |res, i|
        break if limit && i > limit-1
        row do
          res.collect{|k,v| v}.each do |val|
            column(val)
          end
        end
      end
    end
  end
end