Class: Gitlab::RelativePositioning::Gap

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/relative_positioning/gap.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_pos, end_pos) ⇒ Gap

Returns a new instance of Gap.



8
9
10
11
# File 'lib/gitlab/relative_positioning/gap.rb', line 8

def initialize(start_pos, end_pos)
  @start_pos = start_pos
  @end_pos = end_pos
end

Instance Attribute Details

#end_posObject (readonly)

Returns the value of attribute end_pos.



6
7
8
# File 'lib/gitlab/relative_positioning/gap.rb', line 6

def end_pos
  @end_pos
end

#start_posObject (readonly)

Returns the value of attribute start_pos.



6
7
8
# File 'lib/gitlab/relative_positioning/gap.rb', line 6

def start_pos
  @start_pos
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
# File 'lib/gitlab/relative_positioning/gap.rb', line 13

def ==(other)
  other.is_a?(self.class) && other.start_pos == start_pos && other.end_pos == end_pos
end

#deltaObject



17
18
19
# File 'lib/gitlab/relative_positioning/gap.rb', line 17

def delta
  ((start_pos - end_pos) / 2.0).abs.ceil.clamp(0, RelativePositioning::IDEAL_DISTANCE)
end