Sha256: 34910fad14848f0de42c0a2f4523394ac5f2802228a0feb74605536a3ef96e8c
Contents?: true
Size: 626 Bytes
Versions: 20
Compression:
Stored size: 626 Bytes
Contents
module Torque module Range def intersection(other) raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range) new_min = self.cover?(other.min) ? other.min : other.cover?(min) ? min : nil new_max = self.cover?(other.max) ? other.max : other.cover?(max) ? max : nil new_min && new_max ? new_min..new_max : nil end alias_method :&, :intersection def union(other) raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range) ([min, other.min].min)..([max, other.max].max) end alias_method :|, :union end ::Range.include(Range) end
Version data entries
20 entries across 20 versions & 1 rubygems