Sha256: f407a875ab3172039d1d473454f0f4fd413252e1066a23b75865daff3a66796c
Contents?: true
Size: 600 Bytes
Versions: 5
Compression:
Stored size: 600 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 end
Version data entries
5 entries across 5 versions & 1 rubygems