Class: Bundler::Thor::Shell::ColumnPrinter
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Inherits: | Object |
Defined in: | lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb |
Class Method Summary
- .new(stdout, options = {}) ⇒ ColumnPrinter constructor
Instance Attribute Summary
Instance Method Summary
Constructor Details
.new(stdout, options = {}) ⇒ ColumnPrinter
# File 'lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb', line 8
def initialize(stdout, = {}) @stdout = stdout @options = @indent = [:indent].to_i end
Instance Attribute Details
#options (readonly)
[ GitHub ]# File 'lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb', line 6
attr_reader :stdout, :
#stdout (readonly)
[ GitHub ]# File 'lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb', line 6
attr_reader :stdout, :
Instance Method Details
#print(array)
[ GitHub ]# File 'lib/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