Module: Inch::CLI::SparklineHelper
- Included in:
- Command::Output::Stats, Command::Output::Suggest
- Defined in:
- lib/inch/cli/sparkline_helper.rb
Instance Method Summary collapse
Instance Method Details
#grades_sparkline(objects) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/inch/cli/sparkline_helper.rb', line 14 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 |
#ranges_sparkline(_ranges) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/inch/cli/sparkline_helper.rb', line 4 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 |