summaryrefslogtreecommitdiff
path: root/lib/gitlab/word_diff/positions_counter.rb
blob: ca66b43755f173ac2060a869024c60ad3e6ff28a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

# Responsible for keeping track of line numbers and created Gitlab::Diff::Line objects
module Gitlab
  module WordDiff
    class PositionsCounter
      def initialize
        @pos_old = 1
        @pos_new = 1
        @line_obj_index = 0
      end

      attr_reader :pos_old, :pos_new, :line_obj_index

      def increase_pos_num
        @pos_old += 1
        @pos_new += 1
      end

      def increase_obj_index
        @line_obj_index += 1
      end

      def set_pos_num(old:, new:)
        @pos_old = old
        @pos_new = new
      end
    end
  end
end