Sha256: a195dc48bae921991ae9f6ec507be26e4398562e61e1005f250ceca5a2e56e96

Contents?: true

Size: 780 Bytes

Versions: 7

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true
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

7 entries across 7 versions & 1 rubygems

Version Path
rubycritic-3.2.0 lib/rubycritic/generators/html/line.rb
rubycritic-3.1.3 lib/rubycritic/generators/html/line.rb
rubycritic-3.1.2 lib/rubycritic/generators/html/line.rb
rubycritic-3.1.1 lib/rubycritic/generators/html/line.rb
rubycritic-3.1.0 lib/rubycritic/generators/html/line.rb
rubycritic-3.0.0 lib/rubycritic/generators/html/line.rb
rubycritic-2.9.4 lib/rubycritic/generators/html/line.rb