Sha256: 2992ec908a979ecc5e34ef0f531031ead6feb8c2650abbd1823d1fd58c6a8c38

Contents?: true

Size: 707 Bytes

Versions: 3

Compression:

Stored size: 707 Bytes

Contents

module MetricFu::FlogReporter
  class Page < MetricFu::Base::Generator
    attr_accessor :score, :scanned_methods

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

    def to_html
      ERB.new(File.read(template_file)).result(binding)
    end

    def average_score
      sum = 0
      scanned_methods.each do |m|
        sum += m.score
      end
      sum / scanned_methods.length
    end

    def highest_score
      scanned_methods.inject(0) do |highest, m|
        m.score > highest ? m.score : highest
      end
    end

    # should be dynamically read from the class
    def template_name
      'flog_page'
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
indirect-metric_fu-0.8.2 lib/metric_fu/flog_reporter/page.rb
p8-metric_fu-0.8.2 lib/metric_fu/flog_reporter/page.rb
p8-metric_fu-0.8.3 lib/metric_fu/flog_reporter/page.rb