Sha256: 6ae4c3892456acca88a249749b13b5d4b01e032efacd4106588adc80db1c58cb

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

module Inch
  module CLI
    module SparklineHelper
      def grade_lists_sparkline(_grade_lists)
        grade_lists = _grade_lists.reverse
        list = grade_lists.map { |r| r.objects.size }
        __sparkline(list, grade_lists)
      end

      def grades_sparkline(objects)
        grades = {}
        objects.each do |o|
          grades[o.grade.to_sym] ||= 0
          grades[o.grade.to_sym] += 1
        end
        grade_lists = Evaluation.new_grade_lists.reverse
        order = grade_lists.map(&:to_sym)
        list = order.map { |g| grades[g] }
        __sparkline(list, grade_lists)
      end

      def __sparkline(list, grade_lists)
        sparkline = Sparkr::Sparkline.new(list)
        sparkline.format do |tick, _count, index|
          t = tick.color(grade_lists[index].color)
          index == 0 ? t + " " : t
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inch-0.4.7 lib/inch/cli/sparkline_helper.rb