def display_value(bytes)
      return '-'   if bytes.nil?
      return '0 B' if bytes.zero?

      case [Math.log10(bytes.abs).floor, 0].max
      when  0...4  then '%d B'  % bytes
      when  4...7  then '%d kB' % (bytes / 1000)
      when  7...10 then '%d MB' % (bytes / 1_000_000)
      when 10...13 then '%d GB' % (bytes / 1_000_000_000)
      else              '%d TB' % (bytes / 1_000_000_000_000)
      end
    end
def display_value(bytes)
      return '-'   if bytes.nil?
      return '0 B' if bytes.zero?

      case [Math.log10(bytes.abs).floor, 0].max
      when  0...4  then '%d B'  % bytes
      when  4...7  then '%d kB' % (bytes / 1000)
      when  7...10 then '%d MB' % (bytes / 1_000_000)
      when 10...13 then '%d GB' % (bytes / 1_000_000_000)
      else              '%d TB' % (bytes / 1_000_000_000_000)
      end
    end
Formats the traffic number using x B/kB/MB/GB etc notation