Class: Range
- Inherits:
-
Object
- Object
- Range
- Defined in:
- lib/ext/core_ext.rb
Instance Method Summary collapse
- #intersection(other) ⇒ Object (also: #&)
Instance Method Details
#intersection(other) ⇒ Object Also known as: &
12 13 14 15 16 |
# File 'lib/ext/core_ext.rb', line 12 def intersection(other) raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range) return nil if (self.max < other.begin or other.max < self.begin) [self.begin, other.begin].max..[self.max, other.max].min end |