instance method
puts_table
Ruby on Rails 1.2.3
Since v1.1.6 Last seen in v2.2.3 PrivateSignature
puts_table(array)
No documentation comment.
Parameters
-
arrayreq
Source
# File lib/importmap/commands.rb, line 131
def puts_table(array)
column_sizes = array.reduce([]) do |lengths, row|
row.each_with_index.map{ |iterand, index| [lengths[index] || 0, iterand.to_s.length].max }
end
puts head = "+" + (column_sizes.map { |s| "-" * (s + 2) }.join('+')) + '+'
array.each_with_index do |row, row_number|
row = row.fill(nil, row.size..(column_sizes.size - 1))
row = row.each_with_index.map { |v, i| v.to_s + " " * (column_sizes[i] - v.to_s.length) }
puts "| " + row.join(" | ") + " |"
puts head if row_number == 0
end
puts head
end
Defined in lib/importmap/commands.rb line 131
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Importmap::Commands