Class: CoverageItem

Inherits:
Object
  • Object
show all
Defined in:
lib/cobertura/coverage_item.rb

Overview

Container item for cobertura <class> entries

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ CoverageItem

Initialize an object using an xml node set containing the class information of a cobertura report.

Parameters:

  • node (Oga::XML::NodeSet)

    NodeSet of a class



6
7
8
# File 'lib/cobertura/coverage_item.rb', line 6

def initialize(node)
  @node = node
end

Instance Method Details

#branch_rateFloat

Returns The branch coverage rate.

Returns:

  • (Float)

    The branch coverage rate



16
17
18
# File 'lib/cobertura/coverage_item.rb', line 16

def branch_rate
  @branch_rate ||= @node.attribute("branch-rate").value.to_f * 100
end

#filenameString

Returns Name of the class file with directory path.

Returns:

  • (String)

    Name of the class file with directory path



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

def filename
  @filename ||= @node.attribute("filename").value.to_s
end

#line_rateFloat

Returns The line coverage rate.

Returns:

  • (Float)

    The line coverage rate



21
22
23
# File 'lib/cobertura/coverage_item.rb', line 21

def line_rate
  @line_rate ||= @node.attribute("line-rate").value.to_f * 100
end

#nameString

Returns Name of the class file with package structure.

Returns:

  • (String)

    Name of the class file with package structure



31
32
33
# File 'lib/cobertura/coverage_item.rb', line 31

def name
  @name ||= @node.attribute("name").value.to_s
end

#total_percentageFloat

Returns The combined coverage of branch and line rate.

Returns:

  • (Float)

    The combined coverage of branch and line rate



11
12
13
# File 'lib/cobertura/coverage_item.rb', line 11

def total_percentage
  @total_percentage ||= (branch_rate + line_rate) / 2
end