Class: Gitlab::RelativePositioning::Gap
- Inherits:
-
Object
- Object
- Gitlab::RelativePositioning::Gap
- Defined in:
- lib/gitlab/relative_positioning/gap.rb
Instance Attribute Summary collapse
-
#end_pos ⇒ Object
readonly
Returns the value of attribute end_pos.
-
#start_pos ⇒ Object
readonly
Returns the value of attribute start_pos.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #delta ⇒ Object
-
#initialize(start_pos, end_pos) ⇒ Gap
constructor
A new instance of Gap.
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_pos ⇒ Object (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_pos ⇒ Object (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 |
#delta ⇒ Object
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 |