Class: MetricFu::FlogReporter::Page
- Inherits:
-
Base::Generator
- Object
- Base::Generator
- MetricFu::FlogReporter::Page
- Defined in:
- lib/metric_fu/flog_reporter/page.rb
Instance Attribute Summary collapse
-
#scanned_methods ⇒ Object
Returns the value of attribute scanned_methods.
-
#score ⇒ Object
Returns the value of attribute score.
Instance Method Summary collapse
- #average_score ⇒ Object
- #highest_score ⇒ Object
-
#initialize(score, scanned_methods = []) ⇒ Page
constructor
A new instance of Page.
-
#template_name ⇒ Object
should be dynamically read from the class.
- #to_html ⇒ Object
Methods inherited from Base::Generator
#generate_html, #generate_report, generate_report, #link_to_filename, #save_html, #template_file
Constructor Details
#initialize(score, scanned_methods = []) ⇒ Page
Returns a new instance of Page.
5 6 7 8 |
# File 'lib/metric_fu/flog_reporter/page.rb', line 5 def initialize(score, scanned_methods = []) @score = score.to_f @scanned_methods = scanned_methods end |
Instance Attribute Details
#scanned_methods ⇒ Object
Returns the value of attribute scanned_methods.
3 4 5 |
# File 'lib/metric_fu/flog_reporter/page.rb', line 3 def scanned_methods @scanned_methods end |
#score ⇒ Object
Returns the value of attribute score.
3 4 5 |
# File 'lib/metric_fu/flog_reporter/page.rb', line 3 def score @score end |
Instance Method Details
#average_score ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/metric_fu/flog_reporter/page.rb', line 14 def average_score sum = 0 scanned_methods.each do |m| sum += m.score end sum / scanned_methods.length end |
#highest_score ⇒ Object
22 23 24 25 26 |
# File 'lib/metric_fu/flog_reporter/page.rb', line 22 def highest_score scanned_methods.inject(0) do |highest, m| m.score > highest ? m.score : highest end end |
#template_name ⇒ Object
should be dynamically read from the class
29 30 31 |
# File 'lib/metric_fu/flog_reporter/page.rb', line 29 def template_name 'flog_page' end |
#to_html ⇒ Object
10 11 12 |
# File 'lib/metric_fu/flog_reporter/page.rb', line 10 def to_html ERB.new(File.read(template_file)).result(binding) end |