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 << <<-EOF
                <tr class='#{Base.cycle("light", "dark", count)}'>
                  <td class='score'>#{sprintf(SCORE_FORMAT, operator.score)}</td>
                  <td class='score'>#{operator.operator}</td>
                </tr>
              EOF
    count += 1
  end
  output << "</table>\n\n"
end