From 91589afb3f071d86718bec2e23f14a7d4a764c74 Mon Sep 17 00:00:00 2001 From: muflax Date: Mon, 30 Apr 2012 01:02:48 +0200 Subject: [PATCH] make properly commutative --- lib/range_math.rb | 8 +++++++- range_math.gemspec | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/range_math.rb b/lib/range_math.rb index d48eb95..9213a72 100644 --- a/lib/range_math.rb +++ b/lib/range_math.rb @@ -37,7 +37,13 @@ class Range 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 diff --git a/range_math.gemspec b/range_math.gemspec index b896cc2..abf48d4 100644 --- a/range_math.gemspec +++ b/range_math.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "range_math" - s.version = "0.4.0" + s.version = "0.5.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["muflax"]