debian-mirror-gitlab/lib/gitlab/marker_range.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
834 B
Ruby
Raw Normal View History

2021-04-17 20:07:23 +05:30
# frozen_string_literal: true
# It is a Range object extended with `mode` attribute
# MarkerRange not only keeps information about changed characters, but also
# the type of changes
module Gitlab
class MarkerRange < Range
DELETION = :deletion
ADDITION = :addition
# Converts Range object to MarkerRange class
def self.from_range(range)
return range if range.is_a?(self)
new(range.begin, range.end, exclude_end: range.exclude_end?)
end
def initialize(first, last, exclude_end: false, mode: nil)
super(first, last, exclude_end)
@mode = mode
end
def to_range
Range.new(self.begin, self.end, self.exclude_end?)
end
2021-04-29 21:17:54 +05:30
def ==(other)
return false unless other.is_a?(self.class)
self.mode == other.mode && super
end
2021-04-17 20:07:23 +05:30
attr_reader :mode
end
end