Class: Gitlab::Diff::LineMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/diff/line_mapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diff_file) ⇒ LineMapper

Returns a new instance of LineMapper.


11
12
13
# File 'lib/gitlab/diff/line_mapper.rb', line 11

def initialize(diff_file)
  @diff_file = diff_file
end

Instance Attribute Details

#diff_fileObject

Returns the value of attribute diff_file


9
10
11
# File 'lib/gitlab/diff/line_mapper.rb', line 9

def diff_file
  @diff_file
end

Instance Method Details

#new_to_old(new_line) ⇒ Object

Find old line number for new line number.


21
22
23
# File 'lib/gitlab/diff/line_mapper.rb', line 21

def new_to_old(new_line)
  map_line_number(new_line, from: :new_line, to: :old_line)
end

#old_to_new(old_line) ⇒ Object

Find new line number for old line number.


16
17
18
# File 'lib/gitlab/diff/line_mapper.rb', line 16

def old_to_new(old_line)
  map_line_number(old_line, from: :old_line, to: :new_line)
end