Class: MetricFu::FlogReporter::ScannedMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/metric_fu/flog_reporter/scanned_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, score, operators = []) ⇒ ScannedMethod

Returns a new instance of ScannedMethod.



5
6
7
8
9
# File 'lib/metric_fu/flog_reporter/scanned_method.rb', line 5

def initialize(name, score, operators = [])
  @name = name
  @score = score.to_f
  @operators = operators
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/metric_fu/flog_reporter/scanned_method.rb', line 3

def name
  @name
end

#operatorsObject

Returns the value of attribute operators.



3
4
5
# File 'lib/metric_fu/flog_reporter/scanned_method.rb', line 3

def operators
  @operators
end

#scoreObject

Returns the value of attribute score.



3
4
5
# File 'lib/metric_fu/flog_reporter/scanned_method.rb', line 3

def score
  @score
end

Instance Method Details

#to_htmlObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/metric_fu/flog_reporter/scanned_method.rb', line 11

def to_html
  output = "<p><strong>#{name} (#{score})</strong></p>\n"
  output << "<table>\n"
  output << "<tr><th>Score</th><th>Operator</th></tr>\n"
  count = 0
  operators.each do |operator|
    output << "                <tr class='\#{Base.cycle(\"light\", \"dark\", count)}'>\n                  <td class='score'>\#{sprintf(SCORE_FORMAT, operator.score)}</td>\n                  <td class='score'>\#{operator.operator}</td>\n                </tr>\n              EOF\n    count += 1\n  end\n  output << \"</table>\\n\\n\"\nend\n"