Sha256: a5bb54cccc926c004cbcb1d069cc2809b726016823ca92ca9d8efb6ff04cdf83

Contents?: true

Size: 880 Bytes

Versions: 8

Compression:

Stored size: 880 Bytes

Contents

module Inch
  module CLI
    module SparklineHelper
      def ranges_sparkline(_ranges)
        ranges = _ranges.reverse
        list = ranges.map { |r| r.objects.size }
        sparkline = Sparkr::Sparkline.new(list)
        sparkline.format do |tick, count, index|
          t = tick.color(ranges[index].color)
          index == 0 ? t + ' ' : t
        end
      end

      def grades_sparkline(objects)
        grades = {}
        objects.each do |o|
          grades[o.grade] ||= 0
          grades[o.grade] += 1
        end
        ranges = Evaluation.new_score_ranges.reverse
        order = ranges.map(&:grade)
        list = order.map { |g| grades[g] }
        sparkline = Sparkr::Sparkline.new(list)
        sparkline.format do |tick, count, index|
          t = tick.color(ranges[index].color)
          index == 0 ? t + ' ' : t
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
inch-0.2.2 lib/inch/cli/sparkline_helper.rb
inch-0.2.1 lib/inch/cli/sparkline_helper.rb
inch-0.2.0 lib/inch/cli/sparkline_helper.rb
inch-0.1.4 lib/inch/cli/sparkline_helper.rb
inch-0.1.3 lib/inch/cli/sparkline_helper.rb
inch-0.1.2 lib/inch/cli/sparkline_helper.rb
inch-0.1.1 lib/inch/cli/sparkline_helper.rb
inch-0.1.0 lib/inch/cli/sparkline_helper.rb