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 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 ##