File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22language : ruby
33script : " bundle exec qed"
44rvm :
5- - 1.8.7
6- - 1.9.2
5+ - 2.1.0
76 - 1.9.3
7+ - 1.9.2
8+ - 1.8.7
89 - rbx
9- - rbx-19mode
1010 - jruby
11- - jruby-19mode
12-
11+ matrix :
12+ allow_failures :
13+ - rvm : rbx
14+ - rvm : rbx-2
15+ cache : bundler
Original file line number Diff line number Diff line change @@ -40,6 +40,17 @@ def b(base)
4040# instances.
4141class ::String
4242
43+ # Ruby 2.x defines it's own `String#b` method for converting to ASCII 8-bit.
44+ # That breaks Radix (of course), but it a terrbile name. `String#ascii` is
45+ # much better (duh!). So that's what we are doing.
46+ if method_defined? ( :b )
47+ alias :ascii :b
48+ else
49+ def ascii
50+ force_encoding ( 'ASCII' )
51+ end
52+ end
53+
4354 ##
4455 # Takes a String and makes it into a Radix::Integer or Radix::Float as given
4556 # base. Float is determined by a "." character in string instance
@@ -48,7 +59,9 @@ class ::String
4859 # The desired base.
4960 #
5061 # @return [Radix::Integer, Radix::Float]
51- def b ( base )
62+ def b ( base = nil )
63+ return ascii unless base
64+
5265 if index ( '.' )
5366 Radix ::Float . new ( self , base )
5467 else
You can’t perform that action at this time.
0 commit comments