Class: Metricks::FlogReporter::Page
- Inherits:
-
Object
- Object
- Metricks::FlogReporter::Page
- Defined in:
- lib/metricks/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.
- #to_html ⇒ Object
Constructor Details
#initialize(score, scanned_methods = []) ⇒ Page
Returns a new instance of Page.
5 6 7 8 |
# File 'lib/metricks/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/metricks/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/metricks/flog_reporter/page.rb', line 3 def score @score end |
Instance Method Details
#average_score ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/metricks/flog_reporter/page.rb', line 22 def average_score sum = 0 scanned_methods.each do |m| sum += m.score end sum / scanned_methods.length end |
#highest_score ⇒ Object
30 31 32 33 34 |
# File 'lib/metricks/flog_reporter/page.rb', line 30 def highest_score scanned_methods.inject(0) do |highest, m| m.score > highest ? m.score : highest end end |
#to_html ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/metricks/flog_reporter/page.rb', line 10 def to_html output = "<html><head><style>" output << Base.load_css output << "</style></head><body>" output << "Score: #{score}\n" scanned_methods.each do |sm| output << sm.to_html end output << "</body></html>" output end |