Sha256: 4ba4e06dcc2789ca2fb341fba2b451e29e70ef374a677c53469fe16f25ea53fa
Contents?: true
Size: 782 Bytes
Versions: 57
Compression:
Stored size: 782 Bytes
Contents
require_relative "terminal" class Bundler::Thor module Shell class ColumnPrinter attr_reader :stdout, :options def initialize(stdout, options = {}) @stdout = stdout @options = options @indent = options[:indent].to_i end def print(array) return if array.empty? colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2 array.each_with_index do |value, index| # Don't output trailing spaces when printing the last column if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length stdout.puts value else stdout.printf("%-#{colwidth}s", value) end end end end end end
Version data entries
57 entries across 57 versions & 3 rubygems