Class: EagerEye::Fixers::Base
- Inherits:
-
Object
- Object
- EagerEye::Fixers::Base
- Defined in:
- lib/eager_eye/fixers/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#issue ⇒ Object
readonly
Returns the value of attribute issue.
-
#source_lines ⇒ Object
readonly
Returns the value of attribute source_lines.
Instance Method Summary collapse
- #diff ⇒ Object
- #fix ⇒ Object
- #fixable? ⇒ Boolean
-
#initialize(issue, source_code) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(issue, source_code) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 |
# File 'lib/eager_eye/fixers/base.rb', line 8 def initialize(issue, source_code) @issue = issue @source_code = source_code @source_lines = source_code.lines end |
Instance Attribute Details
#issue ⇒ Object (readonly)
Returns the value of attribute issue.
6 7 8 |
# File 'lib/eager_eye/fixers/base.rb', line 6 def issue @issue end |
#source_lines ⇒ Object (readonly)
Returns the value of attribute source_lines.
6 7 8 |
# File 'lib/eager_eye/fixers/base.rb', line 6 def source_lines @source_lines end |
Instance Method Details
#diff ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/eager_eye/fixers/base.rb', line 22 def diff return nil unless fixable? original_line = @source_lines[issue.line_number - 1] fixed_line = fixed_content return nil if original_line == fixed_line { file: issue.file_path, line: issue.line_number, original: original_line.chomp, fixed: fixed_line.chomp } end |
#fix ⇒ Object
18 19 20 |
# File 'lib/eager_eye/fixers/base.rb', line 18 def fix raise NotImplementedError end |
#fixable? ⇒ Boolean
14 15 16 |
# File 'lib/eager_eye/fixers/base.rb', line 14 def fixable? false end |