aboutsummaryrefslogtreecommitdiffstats
path: root/lib/range_ext.rb
diff options
context:
space:
mode:
authorVlatka Pavisic2016-12-30 16:44:30 +0100
committerVlatka Pavisic2016-12-30 16:44:30 +0100
commitad71715b42f5278fb46cedec874cb7e9a4fe3cf3 (patch)
tree67cd1473f7f3c6d7e08401050bceddb16d3daeae /lib/range_ext.rb
parentadfb4aebfab39b5a7a4b9a70ac62f639567aead6 (diff)
downloadchouette-core-ad71715b42f5278fb46cedec874cb7e9a4fe3cf3.tar.bz2
Refs #2262 Refs #2263 Refs #2264 Refs #2265 : Calendars 80% done
Diffstat (limited to 'lib/range_ext.rb')
-rw-r--r--lib/range_ext.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/range_ext.rb b/lib/range_ext.rb
new file mode 100644
index 000000000..5afb44dee
--- /dev/null
+++ b/lib/range_ext.rb
@@ -0,0 +1,7 @@
+class Range
+ def intersection(other)
+ return nil if (self.max < other.begin or other.max < self.begin)
+ [self.begin, other.begin].max..[self.max, other.max].min
+ end
+ alias_method :&, :intersection
+end