Sha256: d9f0c889f0852dbd90c2b40d10ef38b842816f31c2108ffb7bc1eefb3d62d33b
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
#!/usr/bin/env ruby # coding: utf-8 # Copyright muflax <mail@muflax.com>, 2011 # License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html> class Range def +(other) if other.is_a? Range (self.begin + other.begin)..(self.end + other.end) elsif other.is_a? Numeric (self.begin + other)..(self.end + other) else raise NoMethodError end end def -(other) if other.is_a? Range (self.begin - other.begin)..(self.end - other.end) elsif other.is_a? Numeric (self.begin - other)..(self.end - other) else raise NoMethodError end end def *(other) if other.is_a? Range (self.begin * other.begin)..(self.end * other.end) elsif other.is_a? Numeric (self.begin * other)..(self.end * other) else raise NoMethodError end end def /(other) if other.is_a? Range (self.begin / other.begin.to_f)..(self.end / other.end.to_f) elsif other.is_a? Numeric (self.begin / other.to_f)..(self.end / other.to_f) else raise NoMethodError end end def average (self.begin + self.end) / 2.0 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
range_math-0.1.0 | lib/range_math.rb |