Class: Rubycritic::LineGenerator

Inherits:
BaseGenerator show all
Defined in:
lib/rubycritic/report_generators/line_generator.rb

Constant Summary collapse

NORMAL_TEMPLATE =
ERB.new(File.read(File.join(TEMPLATES_DIR, "line.html.erb")))
SMELLY_TEMPLATE =
ERB.new(File.read(File.join(TEMPLATES_DIR, "smelly_line.html.erb")))

Constants inherited from BaseGenerator

BaseGenerator::REPORT_DIR, BaseGenerator::TEMPLATES_DIR

Instance Method Summary collapse

Methods inherited from BaseGenerator

#file_directory, #file_href, #file_name, #file_pathname, #get_binding

Methods included from ViewHelpers

#asset_path, #index_path, #javascript_path, #smell_location_path, #stylesheet_path

Constructor Details

#initialize(text, smells) ⇒ LineGenerator

Returns a new instance of LineGenerator.



11
12
13
14
15
16
17
18
19
20
# File 'lib/rubycritic/report_generators/line_generator.rb', line 11

def initialize(text, smells)
  @text = CGI::escapeHTML(text.chomp)
  @smells = smells
  @template =
    if @smells.empty?
      NORMAL_TEMPLATE
    else
      SMELLY_TEMPLATE
    end
end

Instance Method Details

#renderObject



22
23
24
# File 'lib/rubycritic/report_generators/line_generator.rb', line 22

def render
  @template.result(binding).delete("\n") + "\n"
end