Method: Artic::TimeRange#bisect
- Defined in:
- lib/artic/time_range.rb
#bisect(other) ⇒ Array<TimeRange>
Uses this range to bisect another.
If this range does not overlap the other, returns an array with the original range.
If this range completely covers the other, returns an empty array.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/artic/time_range.rb', line 98 def bisect(other) return [other] unless overlaps?(other) return [] if covers?(other) if self.begin <= other.begin && self.end <= other.end [self.end..other.end] elsif self.begin >= other.begin && self.end <= other.end [ (other.begin..self.begin), (self.end..other.end) ] elsif self.begin >= other.begin && self.end >= other.end [other.begin..self.begin] end end |