Class: SimplecovCovview::CovView::Srcfile::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov_covview/line.rb

Instance Method Summary collapse

Constructor Details

#initialize(line, src_file) ⇒ Line

Create text for each line from @src_files_list.

Parameters:

  • line (Hash)

    @src_files_list

  • src_file (Hash)

    @src_files_list



9
10
11
12
# File 'lib/simplecov_covview/line.rb', line 9

def initialize(line, src_file)
  @line = line
  @src_file = src_file
end

Instance Method Details

#colorize_contentsObject



47
48
49
50
# File 'lib/simplecov_covview/line.rb', line 47

def colorize_contents
  row = SimplecovCovview::CovView::Srcfile::Color.new(status, contents)
  row.colorize
end

#contentsObject



38
39
40
41
42
43
44
45
# File 'lib/simplecov_covview/line.rb', line 38

def contents
  [
    sprintf("%#{line_width}s: ", line_number),
    sprintf("[%7s] ", status),
    sprintf("[%#{cov_width}s ] ", cov_count),
    source_code.chomp("\r\n"),
  ].join
end

#cov_countObject



26
27
28
# File 'lib/simplecov_covview/line.rb', line 26

def cov_count
  @line[:cov]
end

#cov_widthObject



30
31
32
# File 'lib/simplecov_covview/line.rb', line 30

def cov_width
  @src_file[:cov_digit] < 4 ? 4 : @src_file[:cov_digit] + 1
end

#line_numberObject



14
15
16
# File 'lib/simplecov_covview/line.rb', line 14

def line_number
  @line[:num]
end

#line_widthObject



18
19
20
# File 'lib/simplecov_covview/line.rb', line 18

def line_width
  @src_file[:line_digit] < 4 ? 4 : @src_file[:line_digit]
end

#source_codeObject



34
35
36
# File 'lib/simplecov_covview/line.rb', line 34

def source_code
  @line[:src]
end

#statusObject



22
23
24
# File 'lib/simplecov_covview/line.rb', line 22

def status
  @line[:status]
end