Class: Range
Direct Known Subclasses
Instance Method Summary collapse
- #intersection(other) ⇒ Object (also: #&)
Instance Method Details
#intersection(other) ⇒ Object Also known as: &
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/puppet/util/monkey_patches.rb', line 71 def intersection(other) raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range) return unless other === self.first || self === other.first start = [self.first, other.first].max if self.exclude_end? && self.last <= other.last start ... self.last elsif other.exclude_end? && self.last >= other.last start ... other.last else start .. [ self.last, other.last ].min end end |