Class: Policial::CommitFile
- Inherits:
-
Object
- Object
- Policial::CommitFile
- Defined in:
- lib/policial/commit_file.rb
Overview
Public: A file in a commit.
Instance Attribute Summary collapse
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
Instance Method Summary collapse
- #content ⇒ Object
- #filename ⇒ Object
-
#initialize(file, commit) ⇒ CommitFile
constructor
A new instance of CommitFile.
- #line_at(line_number) ⇒ Object
- #removed? ⇒ Boolean
Constructor Details
#initialize(file, commit) ⇒ CommitFile
Returns a new instance of CommitFile.
8 9 10 11 |
# File 'lib/policial/commit_file.rb', line 8 def initialize(file, commit) @file = file @commit = commit end |
Instance Attribute Details
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
6 7 8 |
# File 'lib/policial/commit_file.rb', line 6 def commit @commit end |
Instance Method Details
#content ⇒ Object
17 18 19 20 21 |
# File 'lib/policial/commit_file.rb', line 17 def content @content ||= begin @commit.file_content(filename) unless removed? end end |
#filename ⇒ Object
13 14 15 |
# File 'lib/policial/commit_file.rb', line 13 def filename @file.filename end |
#line_at(line_number) ⇒ Object
27 28 29 30 |
# File 'lib/policial/commit_file.rb', line 27 def line_at(line_number) changed_lines.detect { |line| line.number == line_number } || UnchangedLine.new end |
#removed? ⇒ Boolean
23 24 25 |
# File 'lib/policial/commit_file.rb', line 23 def removed? @file.status == 'removed' end |