Class: ZombieScout::Formatter::ReportFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/zombie_scout/formatter.rb

Instance Attribute Summary

Attributes inherited from BaseFormatter

#mission, #report

Instance Method Summary collapse

Methods inherited from BaseFormatter

#initialize

Constructor Details

This class inherits a constructor from ZombieScout::Formatter::BaseFormatter

Instance Method Details

#to_sObject



20
21
22
23
24
25
26
27
# File 'lib/zombie_scout/formatter.rb', line 20

def to_s
  one = "Scouted #{mission.defined_method_count} methods in #{mission.source_count} files, in #{mission.duration} seconds."
  two = "Found #{mission.zombie_count} potential zombies, with a combined flog score of #{total_flog_score.round(1)}."

  ([one, two, "\n"] + report.map { |zombie|
    [zombie[:location], zombie[:full_name], zombie[:flog_score]] * "\t"
  }) * "\n"
end

#total_flog_scoreObject



29
30
31
# File 'lib/zombie_scout/formatter.rb', line 29

def total_flog_score
  report.map { |z| z[:flog_score] }.reduce(0, :+)
end