class HamlLint::Directive
Handles linter configuration transformation via Haml
comments.
Constants
- DIRECTIVE_REGEXP
- LINTER_REGEXP
Attributes
The names of the linters to act upon.
@return [String]
The mode of the directive. One of “disable” or “enable”.
@return [String]
Public Class Methods
Constructs a directive from source code as a given line.
@param source [String] the source code to analyze @param line [Integer] the line number the source starts at @return [HamlLint::Directive]
# File lib/haml_lint/directive.rb, line 24 def self.from_line(source, line) match = DIRECTIVE_REGEXP.match(source) if match new(source, line, match[:mode], match[:linters].split(/\s*,\s*/)) else Null.new(source, line) end end
Instantiates a new {HamlLint::Directive}
@api semipublic @param source [String] the source code to analyze @param line [Integer] the line number the source starts at @param mode [String] the type of directive, one of “disable” or “enable” @param linters [Array<String>] the name of the linters to act upon
# File lib/haml_lint/directive.rb, line 41 def initialize(source, line, mode, linters) @source = source @line = line @mode = mode @linters = linters end
Public Instance Methods
Checks whether a directive is equivalent to another.
@api public @param other [HamlLint::Directive] the other directive @return [true, false]
# File lib/haml_lint/directive.rb, line 63 def ==(other) super unless other.is_a?(HamlLint::Directive) mode == other.mode && linters == other.linters end
Checks whether this is a disable directive.
@return [true, false]
# File lib/haml_lint/directive.rb, line 72 def disable? mode == 'disable' end
Checks whether this is an enable directive.
@return [true, false]
# File lib/haml_lint/directive.rb, line 79 def enable? mode == 'enable' end
Formats the directive for display in a console.
@return [String]
# File lib/haml_lint/directive.rb, line 86 def inspect "#<HamlLint::Directive(mode=#{mode}, linters=#{linters})>" end