Class: Rubycritic::LineGenerator

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

Constant Summary collapse

NORMAL_TEMPLATE =
erb_template("line.html.erb")
SMELLY_TEMPLATE =
erb_template("smelly_line.html.erb")

Constants inherited from BaseGenerator

BaseGenerator::LAYOUT_TEMPLATE, BaseGenerator::TEMPLATES_DIR

Instance Method Summary collapse

Methods inherited from BaseGenerator

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

Methods included from ViewHelpers

#analysed_file_name, #asset_path, #code_index_path, #javascript_path, #overview_path, #root_directory, #smell_location_path, #smells_index_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