Class: Policial::CommitFile

Inherits:
Object
  • Object
show all
Defined in:
lib/policial/commit_file.rb

Overview

Public: A file in a commit.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commitObject (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

#contentObject



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

#filenameObject



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

Returns:

  • (Boolean)


23
24
25
# File 'lib/policial/commit_file.rb', line 23

def removed?
  @file.status == 'removed'
end