Sha256: 10f6c27ca5b9e87e37434a765c2c176b1775a990c3ab331f0df3281784407081

Contents?: true

Size: 752 Bytes

Versions: 9

Compression:

Stored size: 752 Bytes

Contents

require "cgi"
require "rubycritic/generators/html/base"

module Rubycritic
  module Generator
    module Html

      class Line < Base
        NORMAL_TEMPLATE = erb_template("line.html.erb")
        SMELLY_TEMPLATE = erb_template("smelly_line.html.erb")

        attr_reader :file_directory

        def initialize(file_directory, text, smells)
          @file_directory = file_directory
          @text = CGI.escapeHTML(text.chomp)
          @smells = smells
        end

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

        private

        def template
          if @smells.empty?
            NORMAL_TEMPLATE
          else
            SMELLY_TEMPLATE
          end
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubycritic-2.6.0 lib/rubycritic/generators/html/line.rb
rubycritic-2.5.0 lib/rubycritic/generators/html/line.rb
rubycritic-2.4.1 lib/rubycritic/generators/html/line.rb
rubycritic-2.4.0 lib/rubycritic/generators/html/line.rb
rubycritic-2.3.0 lib/rubycritic/generators/html/line.rb
rubycritic-2.2.0 lib/rubycritic/generators/html/line.rb
rubycritic-2.1.0 lib/rubycritic/generators/html/line.rb
rubycritic-2.0.0 lib/rubycritic/generators/html/line.rb
rubycritic-1.4.0 lib/rubycritic/generators/html/line.rb