class Bundler::Thor::Shell::ColumnPrinter
属性
options[R]
stdout[R]
公共类方法
new(stdout, options = {}) 点击切换源代码
# File bundler/vendor/thor/lib/thor/shell/column_printer.rb, line 8 def initialize(stdout, options = {}) @stdout = stdout @options = options @indent = options[:indent].to_i end
公共实例方法
print(array) 点击切换源代码
# File bundler/vendor/thor/lib/thor/shell/column_printer.rb, line 14 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