Class: Range
- Inherits:
-
Object
- Object
- Range
- Defined in:
- lib/spice_utils.rb
Overview
We need to add some functionality to Range for wndifd
Instance Method Summary (collapse)
-
- (nil, Range) intersection(other)
Find the intersection of two ranges.
Instance Method Details
- (nil, Range) intersection(other)
Find the intersection of two ranges. Used by Spice#wndifd
115 116 117 118 119 120 121 122 123 |
# File 'lib/spice_utils.rb', line 115 def intersection(other) my_min, my_max = first, exclude_end? ? max : last other_min, other_max = other.first, other.exclude_end? ? other.max : other.last new_min = self === other_min ? other_min : other === my_min ? my_min : nil new_max = self === other_max ? other_max : other === my_max ? my_max : nil new_min && new_max ? new_min..new_max : nil end |