Class: CFTools::DEAApps::AppsTable

Inherits:
Object
  • Object
show all
Includes:
CF::Spacing
Defined in:
lib/tools-cf-plugin/dea-apps.rb

Instance Method Summary collapse

Instance Method Details

#render(rows) ⇒ Object



222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/tools-cf-plugin/dea-apps.rb', line 222

def render(rows)
  num_columns = rows.first ? rows.first.size : 0

  rows.each do |row|
    next unless row
    row = row.call if row.respond_to?(:call)

    start_line("")

    row.each.with_index do |col, i|
      next unless col

      width = text_width(col)
      spacings[i] = width if width > spacings[i]

      if i + 1 == num_columns
        print col
      else
        print justify(col, spacings[i])
        print "   "
      end
    end

    line
  end
end

#spacingsObject



218
219
220
# File 'lib/tools-cf-plugin/dea-apps.rb', line 218

def spacings
  @spacings ||= Hash.new(0)
end