class Object
Public Instance Methods
print_row(row)
click to toggle source
# File bin/vl, line 131 def print_row(row) row.each_with_index do |c, i| break if i > $options[:max_n_cols] if i == $options[:max_n_cols] then print "... #{row.size - i} more columns" break end c = c[0..$options[:chop_length]] $max_widths[i] = [$options[:chop_length], $max_widths[i]].min case $options[:justify] when 'l' c = c.ljust($max_widths[i] + $options[:padding]) rescue break when 'r' c = c.rjust($max_widths[i] + $options[:padding]) rescue break when 'a' begin if Float(c) then c = c.rjust($max_widths[i] + $options[:padding]) end rescue c = c.ljust($max_widths[i] + $options[:padding]) end end if $options[:alternate_color] then c = c.colorize([$options[:color_1], $options[:color_2]][i % 2]) end print c end puts rescue Errno::EPIPE => e STDERR.puts 'Pipe ended while writing.' abort end