Class: Gitlab::MarkerRange

Inherits:
Range
  • Object
show all
Defined in:
lib/gitlab/marker_range.rb

Constant Summary collapse

DELETION =
:deletion
ADDITION =
:addition

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(first, last, exclude_end: false, mode: nil) ⇒ MarkerRange

Returns a new instance of MarkerRange.


18
19
20
21
# File 'lib/gitlab/marker_range.rb', line 18

def initialize(first, last, exclude_end: false, mode: nil)
  super(first, last, exclude_end)
  @mode = mode
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.


33
34
35
# File 'lib/gitlab/marker_range.rb', line 33

def mode
  @mode
end

Class Method Details

.from_range(range) ⇒ Object

Converts Range object to MarkerRange class


12
13
14
15
16
# File 'lib/gitlab/marker_range.rb', line 12

def self.from_range(range)
  return range if range.is_a?(self)

  new(range.begin, range.end, exclude_end: range.exclude_end?)
end

Instance Method Details

#==(other) ⇒ Object


27
28
29
30
31
# File 'lib/gitlab/marker_range.rb', line 27

def ==(other)
  return false unless other.is_a?(self.class)

  self.mode == other.mode && super
end

#to_rangeObject


23
24
25
# File 'lib/gitlab/marker_range.rb', line 23

def to_range
  Range.new(self.begin, self.end, self.exclude_end?)
end