lib/amp/support/support.rb
# Given two ranges return the range where they intersect or None.
# 
# >>> intersect((0, 10), (0, 6))
# (0, 6)
# >>> intersect((0, 10), (5, 15))
# (5, 10)
# >>> intersect((0, 10), (10, 15))
# >>> intersect((0, 9), (10, 15))
# >>> intersect((0, 9), (7, 15))
# (7, 9)
Given two ranges return the range where they intersect or None.
Given two ranges return the range where they intersect or None .
def intersect(rb)
    ra = self
    start_a = [ra.begin, rb.begin].max
    start_b = [ra.end,   rb.end  ].min
    if start_a < start_b
      start_a..start_b
    else
      nil
    end
  end
def intersect ( rb ) ra = self start_a = [ ra . begin , rb . begin ] . max start_b = [ ra . end , rb . end ] . min if start_a < start_b start_a .. start_b else nil end end
Given two ranges return the range where they intersect or None.
Given two ranges return the range where they intersect or None .
rb
<not_specific>