Sha256: acb5922dfdb028e941a7c932dc4a7c85272a9f82df1fddfed1e3745df19031ef

Contents?: true

Size: 750 Bytes

Versions: 6

Compression:

Stored size: 750 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

6 entries across 6 versions & 1 rubygems

Version Path
rubycritic-2.9.2 lib/rubycritic/generators/html/line.rb
rubycritic-2.9.1 lib/rubycritic/generators/html/line.rb
rubycritic-2.9.0 lib/rubycritic/generators/html/line.rb
rubycritic-2.8.0 lib/rubycritic/generators/html/line.rb
rubycritic-2.7.1 lib/rubycritic/generators/html/line.rb
rubycritic-2.7.0 lib/rubycritic/generators/html/line.rb