Class: GitDiff::File

Inherits:
Object
  • Object
show all
Defined in:
lib/git_diff/file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFile

Returns a new instance of File.



12
13
14
# File 'lib/git_diff/file.rb', line 12

def initialize
  @hunks = []
end

Instance Attribute Details

#a_blobObject (readonly)

Returns the value of attribute a_blob.



4
5
6
# File 'lib/git_diff/file.rb', line 4

def a_blob
  @a_blob
end

#a_pathObject (readonly)

Returns the value of attribute a_path.



4
5
6
# File 'lib/git_diff/file.rb', line 4

def a_path
  @a_path
end

#b_blobObject (readonly)

Returns the value of attribute b_blob.



4
5
6
# File 'lib/git_diff/file.rb', line 4

def b_blob
  @b_blob
end

#b_modeObject (readonly)

Returns the value of attribute b_mode.



4
5
6
# File 'lib/git_diff/file.rb', line 4

def b_mode
  @b_mode
end

#b_pathObject (readonly)

Returns the value of attribute b_path.



4
5
6
# File 'lib/git_diff/file.rb', line 4

def b_path
  @b_path
end

#hunksObject (readonly)

Returns the value of attribute hunks.



4
5
6
# File 'lib/git_diff/file.rb', line 4

def hunks
  @hunks
end

Class Method Details

.from_string(string) ⇒ Object



6
7
8
9
10
# File 'lib/git_diff/file.rb', line 6

def self.from_string(string)
  if /^diff --git/.match(string)
    File.new
  end
end

Instance Method Details

#<<(string) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/git_diff/file.rb', line 16

def <<(string)
  return if (string)

  if(range_info = RangeInfo.from_string(string))
    add_hunk Hunk.new(range_info)
  else
    append_to_current_hunk string
  end
end

#statsObject



26
27
28
# File 'lib/git_diff/file.rb', line 26

def stats
  @stats ||= Stats.total(collector)
end