Class: GitDiff::LineNumberCalculation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line_number) ⇒ LineNumberCalculation

Returns a new instance of LineNumberCalculation.



7
8
9
# File 'lib/git_diff/line_number_calculation.rb', line 7

def initialize(line_number)
  @current = line_number
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



5
6
7
# File 'lib/git_diff/line_number_calculation.rb', line 5

def current
  @current
end

Instance Method Details

#increment(line) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/git_diff/line_number_calculation.rb', line 11

def increment(line)
  line.line_number = current

  if line.addition?
    current.increment_right
  elsif line.deletion?
    current.increment_left
  else
    current.increment
  end
end