Class: AnalDiffist::FlogDiff

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, previous_score, current_score) ⇒ FlogDiff

Returns a new instance of FlogDiff.



49
50
51
52
53
# File 'lib/analdiffist/flog_parser.rb', line 49

def initialize context, previous_score, current_score
  @context = context
  @current_score = current_score
  @previous_score = previous_score
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



48
49
50
# File 'lib/analdiffist/flog_parser.rb', line 48

def context
  @context
end

#scoreObject

Returns the value of attribute score.



48
49
50
# File 'lib/analdiffist/flog_parser.rb', line 48

def score
  @score
end

Instance Method Details

#description(mode = :added) ⇒ Object



64
65
66
67
# File 'lib/analdiffist/flog_parser.rb', line 64

def description(mode = :added)
  indicator = (mode == :added) ? "+" : ""
  "Flog: #{@current_score.round(1)} (#{indicator}#{(@current_score - @previous_score).round(1)})"
end

#invert!Object



59
60
61
62
# File 'lib/analdiffist/flog_parser.rb', line 59

def invert!
  score = 0 - (score || 0)
  self
end