From 82997ef602e2a1fac8730c8437ec119e688d625f Mon Sep 17 00:00:00 2001 From: Andreas Salme Date: Wed, 9 Jul 2014 18:13:21 -0700 Subject: [PATCH 1/2] fix conflicting String#b implementation in ruby 2.x --- lib/radix/operator.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/radix/operator.rb b/lib/radix/operator.rb index 0a78bf5..c15bf92 100644 --- a/lib/radix/operator.rb +++ b/lib/radix/operator.rb @@ -48,13 +48,26 @@ class ::String # The desired base. # # @return [Radix::Integer, Radix::Float] - def b(base) + def b_with_radix(base = nil) + # assume this is the ruby String#b being called if base is nil + return b_without_radix if base.nil? && respond_to?(:b_without_radix) + if index('.') Radix::Float.new(self, base) else Radix::Integer.new(self, base) end end + + # String#b in Radix conflicts with String#b in ruby 2.x + # to get around this without breaking the Radix API + # we can set up a method chain + if "".respond_to?(:b) + alias_method :b_without_radix, :b + alias_method :b, :b_with_radix + else + alias :b :b_with_radix + end end ## From e00382cb2ca78ad5f379f39aff317c8bd323e855 Mon Sep 17 00:00:00 2001 From: Andreas Salme Date: Thu, 10 Jul 2014 11:38:47 -0700 Subject: [PATCH 2/2] remove deprecated rbx-19mode from travis build --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 877fc99..6b831b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,7 @@ rvm: - 1.8.7 - 1.9.2 - 1.9.3 - - rbx - - rbx-19mode + - rbx-2 - jruby - jruby-19mode