class Grit::DiffHeader

Attributes

added_count[R]
added_start[R]
count[R]
removed_count[R]
removed_start[R]
start[R]

Public Class Methods

new(hunk_header) click to toggle source
# 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

Private Instance Methods

get_numbers(s) click to toggle source
# File lib/grit/ext/diff_header.rb, line 21
def get_numbers(s)
  start, count = s.split(',')
  [start.to_i, count.to_i]
end
to_s() click to toggle source
# File lib/grit/ext/diff_header.rb, line 26
def to_s
  "@@ -#{removed_start},#{removed_count} +#{added_start},#{added_count} @@"
end