Class: RuboCop::Git::CommitFile
- Inherits:
-
Object
- Object
- RuboCop::Git::CommitFile
- Defined in:
- lib/rubocop/git/commit_file.rb
Overview
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(file, contents) ⇒ CommitFile
constructor
A new instance of CommitFile.
- #modified_line_at(line_number) ⇒ Object
- #modified_lines ⇒ Object
- #relevant_line?(line_number) ⇒ Boolean
- #removed? ⇒ Boolean
- #ruby? ⇒ Boolean
Constructor Details
#initialize(file, contents) ⇒ CommitFile
Returns a new instance of CommitFile.
6 7 8 9 |
# File 'lib/rubocop/git/commit_file.rb', line 6 def initialize(file, contents) @file = file @contents = contents end |
Instance Attribute Details
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
4 5 6 |
# File 'lib/rubocop/git/commit_file.rb', line 4 def contents @contents end |
Instance Method Details
#filename ⇒ Object
11 12 13 |
# File 'lib/rubocop/git/commit_file.rb', line 11 def filename @file.filename end |
#modified_line_at(line_number) ⇒ Object
33 34 35 36 37 |
# File 'lib/rubocop/git/commit_file.rb', line 33 def modified_line_at(line_number) modified_lines.detect do |modified_line| modified_line.line_number == line_number end end |
#modified_lines ⇒ Object
29 30 31 |
# File 'lib/rubocop/git/commit_file.rb', line 29 def modified_lines @modified_lines ||= patch.additions end |
#relevant_line?(line_number) ⇒ Boolean
15 16 17 18 19 |
# File 'lib/rubocop/git/commit_file.rb', line 15 def relevant_line?(line_number) modified_lines.detect do |modified_line| modified_line.line_number == line_number end end |
#removed? ⇒ Boolean
21 22 23 |
# File 'lib/rubocop/git/commit_file.rb', line 21 def removed? @file.status == 'removed' end |
#ruby? ⇒ Boolean
25 26 27 |
# File 'lib/rubocop/git/commit_file.rb', line 25 def ruby? filename.match(/.*\.rb$/) end |