Class: AnalDiffist::FlogProblem

Inherits:
Object
  • Object
show all
Defined in:
lib/analdiffist/flog_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_method, score, threshold = 10) ⇒ FlogProblem

Returns a new instance of FlogProblem.



22
23
24
25
26
# File 'lib/analdiffist/flog_parser.rb', line 22

def initialize class_method, score, threshold = 10
  @context = class_method || '(none)'
  @score = score.round(1)
  @flog_threshold = threshold
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



21
22
23
# File 'lib/analdiffist/flog_parser.rb', line 21

def context
  @context
end

#scoreObject

Returns the value of attribute score.



21
22
23
# File 'lib/analdiffist/flog_parser.rb', line 21

def score
  @score
end

Instance Method Details

#descriptionObject



42
43
44
# File 'lib/analdiffist/flog_parser.rb', line 42

def description
  "Flog: #{score}"
end

#diff(other) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/analdiffist/flog_parser.rb', line 32

def diff other
  if other.nil?
    return nil if score < @flog_threshold
    return FlogDiff.new(@context, 0, score)
  end
  return nil if other.score == score
  return nil if score < @flog_threshold && other.score < @flog_threshold
  FlogDiff.new(@context, other.score, score)
end

#typeObject



28
29
30
# File 'lib/analdiffist/flog_parser.rb', line 28

def type
  'flog score'
end