# File lib/powerbar.rb, line 237
  def bar
    return nil if state.total.is_a? Symbol
    skel   = render_template(:main, [:bar])
    lwid   = state.scope_at[0] == :tty ? terminal_width() : scope.line_width
    barlen = [lwid - skel.gsub(STRIP_ANSI, '').length, 0].max
    fill   = [0,[(state.done.to_f/state.total*barlen).to_i,barlen].min].max
    thebar = scope.template.barchar * fill + scope.template.padchar * [barlen - fill,0].max
    thebar.length == 0 ? nil : thebar
  end