Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gap.rb « relative_positioning « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ab894141a601dbee2d74afaf0590b5f0b2d47f7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true
#
module Gitlab
  module RelativePositioning
    class Gap
      attr_reader :start_pos, :end_pos

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

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

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