Sha256: 3c2fba306fddffb903e95c8e7845c25fd39f8789a121163fe8b62c37747e43d9

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true

module GitDiff
  class LineNumber
    attr_reader :left, :right

    module ClassMethods
      def for_addition(line_number)
        new(nil, line_number.right)
      end

      def for_deletion(line_number)
        new(line_number.left, nil)
      end

      def for_context(line_number)
        new(line_number.left, line_number.right)
      end
    end
    extend ClassMethods

    def initialize(left, right)
      @left = left
      @right = right
    end

    def increment_left
      @left += 1
    end

    def increment_right
      @right += 1
    end

    def increment
      increment_left
      increment_right
    end

    def pair
      [left, right]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_diff-0.4.3 lib/git_diff/line_number.rb