Class: Gitlab::RelativePositioning::Range
- Inherits:
-
Object
- Object
- Gitlab::RelativePositioning::Range
show all
- Defined in:
- lib/gitlab/relative_positioning/range.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#lhs ⇒ Object
Returns the value of attribute lhs.
6
7
8
|
# File 'lib/gitlab/relative_positioning/range.rb', line 6
def lhs
@lhs
end
|
#rhs ⇒ Object
Returns the value of attribute rhs.
6
7
8
|
# File 'lib/gitlab/relative_positioning/range.rb', line 6
def rhs
@rhs
end
|
Instance Method Details
#==(other) ⇒ Object
30
31
32
|
# File 'lib/gitlab/relative_positioning/range.rb', line 30
def ==(other)
other.is_a?(RelativePositioning::Range) && lhs == other.lhs && rhs == other.rhs
end
|
#cover?(item_context) ⇒ Boolean
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/gitlab/relative_positioning/range.rb', line 16
def cover?(item_context)
return false unless item_context
return false unless item_context.positioned?
return true if item_context.object == lhs&.object
return true if item_context.object == rhs&.object
pos = item_context.relative_position
return lhs.relative_position < pos if open_on_right?
return pos < rhs.relative_position if open_on_left?
lhs.relative_position < pos && pos < rhs.relative_position
end
|
#open_on_left? ⇒ Boolean
8
9
10
|
# File 'lib/gitlab/relative_positioning/range.rb', line 8
def open_on_left?
lhs.nil?
end
|
#open_on_right? ⇒ Boolean
12
13
14
|
# File 'lib/gitlab/relative_positioning/range.rb', line 12
def open_on_right?
rhs.nil?
end
|