class HTTPLogAnalyzer::Stats::BarGraphItem

Public Class Methods

new(label:, count:, total:, width: 50) click to toggle source
# File lib/http-log-analyzer/stats.rb, line 53
def initialize(label:, count:, total:, width: 50)
  @label = label
  @count = count
  @total = total
  @width = width
  @fraction = @count.to_f / @total
end

Public Instance Methods

bar() click to toggle source
# File lib/http-log-analyzer/stats.rb, line 61
def bar
  n = (@fraction * @width).ceil.to_i
  ('.' * (@width - n)) + ('#' * n)
end
to_s() click to toggle source
# File lib/http-log-analyzer/stats.rb, line 66
def to_s
  '%s %3d%% %6d  %s' % [
    bar,
    (@fraction * 100).ceil.to_i,
    @count,
    @label,
  ]
end