Class: Grit::DiffHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/grit/ext/diff_header.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hunk_header) ⇒ DiffHeader

Returns a new instance of DiffHeader.



9
10
11
12
13
14
15
16
17
# File 'lib/grit/ext/diff_header.rb', line 9

def initialize(hunk_header)
  groups = hunk_header.split('-')[1].split('+')

  removed = groups.first.strip
  added = groups.last.sub(' @@', '').strip

  @removed_start, @removed_count = get_numbers(removed)
  @added_start, @added_count = get_numbers(added)
end

Instance Attribute Details

#added_countObject (readonly) Also known as: count

Returns the value of attribute added_count.



3
4
5
# File 'lib/grit/ext/diff_header.rb', line 3

def added_count
  @added_count
end

#added_startObject (readonly) Also known as: start

Returns the value of attribute added_start.



3
4
5
# File 'lib/grit/ext/diff_header.rb', line 3

def added_start
  @added_start
end

#removed_countObject (readonly)

Returns the value of attribute removed_count.



3
4
5
# File 'lib/grit/ext/diff_header.rb', line 3

def removed_count
  @removed_count
end

#removed_startObject (readonly)

Returns the value of attribute removed_start.



3
4
5
# File 'lib/grit/ext/diff_header.rb', line 3

def removed_start
  @removed_start
end