Class: MetricFu::Flog::Page
- Inherits:
-
Base::Generator
- Object
- Base::Generator
- MetricFu::Flog::Page
- Defined in:
- lib/metric_fu/flog.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#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.
- #path ⇒ Object
- #template_name ⇒ Object
- #to_html ⇒ Object
Methods inherited from Base::Generator
#generate_html, generate_report, #generate_report, metric_dir, #save_html, #template_file, template_name
Methods included from TemplateHelpers
#cycle, #inline_css, #link_to_filename
Constructor Details
#initialize(score, scanned_methods = []) ⇒ Page
Returns a new instance of Page.
77 78 79 80 |
# File 'lib/metric_fu/flog.rb', line 77 def initialize(score, scanned_methods = []) @score = score.to_f @scanned_methods = scanned_methods end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
75 76 77 |
# File 'lib/metric_fu/flog.rb', line 75 def filename @filename end |
#scanned_methods ⇒ Object
Returns the value of attribute scanned_methods.
75 76 77 |
# File 'lib/metric_fu/flog.rb', line 75 def scanned_methods @scanned_methods end |
#score ⇒ Object
Returns the value of attribute score.
75 76 77 |
# File 'lib/metric_fu/flog.rb', line 75 def score @score end |
Instance Method Details
#average_score ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/metric_fu/flog.rb', line 90 def average_score return 0 if scanned_methods.length == 0 sum = 0 scanned_methods.each do |m| sum += m.score end sum / scanned_methods.length end |
#highest_score ⇒ Object
99 100 101 102 103 |
# File 'lib/metric_fu/flog.rb', line 99 def highest_score scanned_methods.inject(0) do |highest, m| m.score > highest ? m.score : highest end end |
#path ⇒ Object
82 83 84 |
# File 'lib/metric_fu/flog.rb', line 82 def path @path ||= File.basename(filename, ".txt") + '.html' end |
#template_name ⇒ Object
105 106 107 |
# File 'lib/metric_fu/flog.rb', line 105 def template_name 'flog_page' end |
#to_html ⇒ Object
86 87 88 |
# File 'lib/metric_fu/flog.rb', line 86 def to_html ERB.new(File.read(template_file)).result(binding) end |