class HamlLint::Severity
Models the severity of a lint
Constants
- COLORS
- MARKS
- NAMES
- SEVERITY_ERROR
- SEVERITY_WARNING
Public Class Methods
new(name)
click to toggle source
Creates a new severity for a lint
@example
HamlLint::Severity.new(:warning)
@api public @param name [Symbol] the name of the severity level
Calls superclass method
# File lib/haml_lint/severity.rb, line 23 def initialize(name) name = name.name if name.is_a?(Severity) name ||= :warning fail Exceptions::UnknownSeverity, "Unknown severity: #{name}" unless NAMES.include?(name) super end
Public Instance Methods
<=>(other)
click to toggle source
Compares the severity to another severity or a symbol
@return [Integer]
# File lib/haml_lint/severity.rb, line 91 def <=>(other) other = Severity.new(other) unless other.respond_to?(:level) level <=> other.level end
color()
click to toggle source
The color of the mark in reporters.
@return [Symbol]
# File lib/haml_lint/severity.rb, line 33 def color COLORS[__getobj__] end
error?()
click to toggle source
Checks whether the severity is an error
@example
HamlLint::Severity.new(:error).error? #=> true
@api public @return [Boolean]
# File lib/haml_lint/severity.rb, line 44 def error? __getobj__ == :error end
level()
click to toggle source
The level of severity for the lint
@api public @return [Integer]
# File lib/haml_lint/severity.rb, line 52 def level NAMES.index(__getobj__) + 1 end
mark()
click to toggle source
The symbol to use in a {HamlLint::Reporter::ProgressReporter}.
@returns [String]
# File lib/haml_lint/severity.rb, line 59 def mark MARKS[__getobj__] end
mark_with_color()
click to toggle source
The colorized symbol to use in a reporter.
@returns [String]
# File lib/haml_lint/severity.rb, line 66 def mark_with_color Rainbow.global.wrap(mark).public_send(color) end
name()
click to toggle source
The name of the severity.
@returns [Symbol]
# File lib/haml_lint/severity.rb, line 73 def name __getobj__ end
warning?()
click to toggle source
Checks whether the severity is a warning
@example
HamlLint::Severity.new(:warning).warning? #=> true
@api public @return [Boolean]
# File lib/haml_lint/severity.rb, line 84 def warning? __getobj__ == :warning end