Class: SCSSLint::AutoCorrect::Correctors::ShorterVersionsOfColors
- Inherits:
-
Base
- Object
- Base
- SCSSLint::AutoCorrect::Correctors::ShorterVersionsOfColors
show all
- Defined in:
- lib/scss_lint/auto_correct/correctors/shorter_versions_of_colors.rb
Instance Attribute Summary
Attributes inherited from Base
#config
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#enabled?, #initialize, priority, short_name
Class Method Details
.description ⇒ Object
11
12
13
|
# File 'lib/scss_lint/auto_correct/correctors/shorter_versions_of_colors.rb', line 11
def self.description
"Shortens hex color codes to 3 letters, when possible"
end
|
.linter_name ⇒ Object
7
8
9
|
# File 'lib/scss_lint/auto_correct/correctors/shorter_versions_of_colors.rb', line 7
def self.linter_name
"HexLength"
end
|
Instance Method Details
#call(contents) ⇒ Object
3
4
5
|
# File 'lib/scss_lint/auto_correct/correctors/shorter_versions_of_colors.rb', line 3
def call(contents)
contents.gsub(/#(([A-Za-z0-9])\2){3}/) { |m| "##{m[1]}#{m[3]}#{m[5]}" }
end
|