Method: B::ConsoleWriter#start

Defined in:
lib/b/output_plugins.rb

#start(job) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/b/output_plugins.rb', line 87

def start(job)
  if @header_printed.nil?
    @header_printed = true

    # add :x column if this is a comparison
    if job.compare
      @columns << [:x, "x #{job.compare}", @opts[:column_width], @opts[:round], 1]
    end

    # print header
    header = '-' * (@columns.transpose[C_WIDTH].reduce(&:+) + @columns.length - 1)
    header[2..3+job.group.length] = " #{job.group} "
    printf header + "\n"
    @columns.each_with_index do |col, i|
      printf col[C_LABEL].rjust(col[C_WIDTH]) + ' '
    end
    printf "\n"
  end
  # print job.label
  printf "#{job.id[0..@columns[0][C_WIDTH]-1].ljust(@columns[0][C_WIDTH])} "
  # print rounds
  printf "%#{@columns[1][C_WIDTH]}d ", job.send(:rounds)
end