Sha256: fe32eb73f0c7c76904ba616492141197706f7e96033ce17b3c17d53fc453e57b

Contents?: true

Size: 753 Bytes

Versions: 1

Compression:

Stored size: 753 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
      return 0 if scanned_methods.length == 0
      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

1 entries across 1 versions & 1 rubygems

Version Path
p8-metric_fu-0.8.4 lib/metric_fu/flog_reporter/page.rb