Method: VagrantPlugininspection::UI::Columnized::Layout#rows

Defined in:
lib/vagrant-plugins/ui.rb

#rows(data, opts = nil) ⇒ Array

Returns an Array of columns formatted lines. Also includes column headers and horizonal header line.

Returns:

  • (Array)

    Returns an Array of formatted lines



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/vagrant-plugins/ui.rb', line 45

def rows(data, opts=nil)
  defaults = { :heads => true }
  opts     = defaults.merge(opts || {})

  data = clean(data)
  size = sizes(data)

  rendered = Array.new
  if opts.delete(:heads)
    rendered << columnize_row(@heads, size)
    rendered << horizontal_line(size)
  end
  rendered << data.map { |line| columnize_row(line, size) }

  # return a flat Array with lines
  rendered.flatten
end