class Heroku::Command::Pgbackups::Display::DataSource

Attributes

columns[R]
rows[R]

Public Class Methods

new(data, opts={}) click to toggle source
# File lib/heroku/command/pgbackups.rb, line 293
def initialize(data, opts={})
  rows = []
  data.each { |d| rows += d }
  columns = rows.transpose

  max_widths = columns.map { |c|
    c.map { |datum| datum.length }.max
  }

  max_widths = [10, 10] if opts[:display_columns]

  @columns = []
  columns.each_with_index { |c,i|
    column = @columns[i] = []
    c.each { |d| column << d.ljust(max_widths[i]) }
  }
  @rows = @columns.transpose
end