lib/range_math.rb in range_math-0.4.0 vs lib/range_math.rb in range_math-0.5.0
- old
+ new
@@ -35,10 +35,16 @@
def average
(self.begin + self.end) / 2.0
end
def coerce(other)
- return self, other
+ if other.is_a? Range
+ return other, self
+ elsif other.is_a? Numeric
+ return (other..other), self
+ else
+ super
+ end
end
def pair_or_num operator, other
if other.is_a? Range
calc_pairs operator, other