Class: Watchr::FlogReportClass

Inherits:
Object
  • Object
show all
Defined in:
lib/watchr/metrics/flog/class.rb

Overview

Flog report class information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, score) ⇒ FlogReportClass

Returns a new instance of FlogReportClass.



8
9
10
11
12
# File 'lib/watchr/metrics/flog/class.rb', line 8

def initialize(name, score)
  @name = name
  @total_score = (10 * score).round / 10.0
  @methods = []
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



6
7
8
# File 'lib/watchr/metrics/flog/class.rb', line 6

def location
  @location
end

#methodsObject (readonly)

Returns the value of attribute methods.



6
7
8
# File 'lib/watchr/metrics/flog/class.rb', line 6

def methods
  @methods
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/watchr/metrics/flog/class.rb', line 6

def name
  @name
end

#total_scoreObject (readonly)

Returns the value of attribute total_score.



6
7
8
# File 'lib/watchr/metrics/flog/class.rb', line 6

def total_score
  @total_score
end

Instance Method Details

#add_method(method_report) ⇒ Object



22
23
24
25
# File 'lib/watchr/metrics/flog/class.rb', line 22

def add_method(method_report)
  @methods << method_report
  @location = Location.new(method_report.location.file)
end

#total_methods_scoreObject



18
19
20
# File 'lib/watchr/metrics/flog/class.rb', line 18

def total_methods_score
  @methods.reduce(0) {|sum, method| sum += method.total_score}
end