Sha256: 062e7d6625d5ff92042657d7597a5fb7ef67ab5422f05eba1f11a4645e99dd03
Contents?: true
Size: 744 Bytes
Versions: 34
Compression:
Stored size: 744 Bytes
Contents
# frozen_string_literal: true module DeepCover module Tools::NumberLines def number_lines(lines, lineno: 1, bad_linenos: []) max_lineno = lineno + lines.size - 1 nb_lineno_digits = max_lineno.to_s.size lines.map.with_index do |line, i| cur_lineno = lineno + i cur_lineno_s = cur_lineno.to_s.rjust(nb_lineno_digits) if bad_linenos.include?(cur_lineno) cur_lineno_s = "*#{cur_lineno_s}" unless bad_linenos.empty? prefix = Term::ANSIColor.red("#{cur_lineno_s} | ") else cur_lineno_s = " #{cur_lineno_s}" unless bad_linenos.empty? prefix = Term::ANSIColor.white("#{cur_lineno_s} | ") end "#{prefix}#{line}" end end end end
Version data entries
34 entries across 34 versions & 2 rubygems