Sha256: f389e9b7f9096dfbb12e68b7c87632513f1e0ffa6582fd72adab429c06eb70a0

Contents?: true

Size: 573 Bytes

Versions: 13

Compression:

Stored size: 573 Bytes

Contents

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)
          prefix = Term::ANSIColor.red("#{cur_lineno_s} | ")
        else
          prefix = Term::ANSIColor.white("#{cur_lineno_s} | ")
        end
        "#{prefix}#{line}"
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
deep-cover-0.1.13 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.12 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.11 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.10 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.9 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.8 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.7 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.6 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.5 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.4 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.3 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.2 lib/deep_cover/tools/number_lines.rb
deep-cover-0.1.1 lib/deep_cover/tools/number_lines.rb