Class: ERBLint::Corrector
- Inherits:
-
Object
- Object
- ERBLint::Corrector
- Defined in:
- lib/erb_lint/corrector.rb
Instance Attribute Summary collapse
-
#corrected_content ⇒ Object
readonly
Returns the value of attribute corrected_content.
-
#offenses ⇒ Object
readonly
Returns the value of attribute offenses.
-
#processed_source ⇒ Object
readonly
Returns the value of attribute processed_source.
Instance Method Summary collapse
- #correct!(corrector) ⇒ Object
- #corrections ⇒ Object
-
#initialize(processed_source, offenses) ⇒ Corrector
constructor
A new instance of Corrector.
Constructor Details
#initialize(processed_source, offenses) ⇒ Corrector
Returns a new instance of Corrector.
7 8 9 10 11 12 13 |
# File 'lib/erb_lint/corrector.rb', line 7 def initialize(processed_source, offenses) @processed_source = processed_source @offenses = offenses corrector = RuboCop::Cop::Corrector.new(@processed_source.source_buffer) correct!(corrector) @corrected_content = corrector.rewrite end |
Instance Attribute Details
#corrected_content ⇒ Object (readonly)
Returns the value of attribute corrected_content.
5 6 7 |
# File 'lib/erb_lint/corrector.rb', line 5 def corrected_content @corrected_content end |
#offenses ⇒ Object (readonly)
Returns the value of attribute offenses.
5 6 7 |
# File 'lib/erb_lint/corrector.rb', line 5 def offenses @offenses end |
#processed_source ⇒ Object (readonly)
Returns the value of attribute processed_source.
5 6 7 |
# File 'lib/erb_lint/corrector.rb', line 5 def processed_source @processed_source end |
Instance Method Details
#correct!(corrector) ⇒ Object
21 22 23 24 25 |
# File 'lib/erb_lint/corrector.rb', line 21 def correct!(corrector) corrections.each do |correction| correction.call(corrector) end end |
#corrections ⇒ Object
15 16 17 18 19 |
# File 'lib/erb_lint/corrector.rb', line 15 def corrections @corrections ||= @offenses.map do |offense| offense.linter.autocorrect(@processed_source, offense) if offense.linter.class.support_autocorrect? end.compact end |