class GCOV::Line

Attributes

count[R]
number[R]
text[R]

Public Class Methods

new(number, count, text) click to toggle source
# File lib/line.rb, line 8
def initialize number, count, text
  @number = number
  @count = count
  @text = text
end
parse(line) click to toggle source
# File lib/line.rb, line 22
def self.parse line
  match = /^[ ]*([0-9]+|-|#####):[ ]*([0-9]+):(.*)/.match(line)
  fail "Invalid line: #{line}" unless match.to_a.count == 4
  count,number,text = match.to_a[1..3]
  number = number.to_i
  count = case count.strip
          when "-" then :none
          when "#####" then :missed
          else count.to_i
          end
  GCOV::Line.new number,count,text
end

Public Instance Methods

merge(other) click to toggle source
# File lib/line.rb, line 47
def merge other
  result = self.dup
  result.merge! other
  result
end
merge!(other) click to toggle source
# File lib/line.rb, line 35
def merge! other
  if other.count.is_a? Integer and @count.is_a? Integer
    @count += other.count
  elsif other.count.is_a? Integer
    @count = other.count
  elsif @count.is_a? Integer
    nil
  elsif other.count == :missed or @count == :missed
    @count = :missed
  end
end
state() click to toggle source
# File lib/line.rb, line 14
def state
  case @count
  when :missed then :missed
  when :none then :none
  else :exec
  end
end