Class: Bugwatch::ComplexityScore

Inherits:
Object
  • Object
show all
Defined in:
lib/bugwatch/complexity_score.rb

Constant Summary collapse

DEFAULT_COMPLEXITY =
0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, before_score, after_score) ⇒ ComplexityScore

Returns a new instance of ComplexityScore.



39
40
41
42
43
# File 'lib/bugwatch/complexity_score.rb', line 39

def initialize(file, before_score, after_score)
  @file = file
  @before_score = before_score
  @after_score = after_score
end

Instance Attribute Details

#after_scoreObject (readonly)

Returns the value of attribute after_score.



37
38
39
# File 'lib/bugwatch/complexity_score.rb', line 37

def after_score
  @after_score
end

#before_scoreObject (readonly)

Returns the value of attribute before_score.



37
38
39
# File 'lib/bugwatch/complexity_score.rb', line 37

def before_score
  @before_score
end

#fileObject (readonly)

Returns the value of attribute file.



37
38
39
# File 'lib/bugwatch/complexity_score.rb', line 37

def file
  @file
end

Instance Method Details

#accumulatedObject



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/bugwatch/complexity_score.rb', line 45

def accumulated
  if before_score && after_score
    after_score - before_score
  elsif after_score
    after_score
  elsif before_score
    -before_score
  else
    DEFAULT_COMPLEXITY
  end
end