Class: CC::Analyzer::Formatters::HTMLFormatter::ReportTemplate

Inherits:
Object
  • Object
show all
Includes:
ERB::Util
Defined in:
lib/cc/analyzer/formatters/html_formatter.rb

Constant Summary collapse

TEMPLATE_PATH =
File.expand_path(File.join(File.dirname(__FILE__), "templates/html.erb"))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue_count, issues_by_path) ⇒ ReportTemplate

Returns a new instance of ReportTemplate.



14
15
16
17
18
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 14

def initialize(issue_count, issues_by_path)
  @template = File.read(TEMPLATE_PATH)
  @issues_by_path = issues_by_path
  @issue_count = issue_count
end

Instance Attribute Details

#issuesObject

Returns the value of attribute issues.



10
11
12
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 10

def issues
  @issues
end

#issues_by_pathObject

Returns the value of attribute issues_by_path.



10
11
12
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 10

def issues_by_path
  @issues_by_path
end

#templateObject

Returns the value of attribute template.



10
11
12
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 10

def template
  @template
end

Instance Method Details

#pluralize(number, noun) ⇒ Object



24
25
26
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 24

def pluralize(number, noun)
  "#{ActiveSupport::NumberHelper.number_to_delimited(number)} #{noun.pluralize(number)}"
end

#renderObject



20
21
22
# File 'lib/cc/analyzer/formatters/html_formatter.rb', line 20

def render
  ERB.new(@template).result(binding)
end