Browse files

bump to 0.0.6

  • Loading branch information...
1 parent 220a6a8 commit f65406afc0adc66f6d2fcab2f64cffd5f062ba6d @kachick committed Sep 12, 2012
Showing with 18 additions and 16 deletions.
  1. +2 −1 README.md
  2. +2 −1 lib/integer/base.rb
  3. +2 −2 lib/integer/base/core_ext.rb
  4. +12 −12 lib/integer/base/singleton_class.rb
View
3 README.md
@@ -25,6 +25,7 @@ require 'integer/base'
Integer::Base.parse '10', %w[0 1 2 3 4 5 6 7 8 9] #=> 10
Integer::Base.parse '10', %w[0 1] #=> 2
+Integer::Base.string_for 10, %w[0 1] #=> '2'
require 'integer/base/core_ext'
@@ -43,7 +44,7 @@ require 'integer/base/core_ext'
'1?'.to_s [*'0'..'9', *'A'..'Z', '?'] #=> '73' (37 * 1 + 36 * 1)
```
-### Appendix. Let's begin, your strange base number.
+### Let's begin, your strange base number.
```ruby
View
3 lib/integer/base.rb
@@ -5,7 +5,8 @@ class Integer
module Base
class InvalidCharacterError < TypeError; end
-
+
+ # @return [Regexp]
SPECIAL_CHAR_PATTERN = /[\x00-\x20\-\+]/
# @return [Hash]
View
4 lib/integer/base/core_ext.rb
@@ -8,7 +8,7 @@ class String
# @overload to_i(base_number)
# @param [Fixnum] base_number Delegate to standard to_i
# @overload to_i(positional_chars)
- # @param [Array<#to_sym>] positional_chars
+ # @param [Array<Symbol, String, #to_sym>] positional_chars
# @return [Integer]
def to_i(base=10)
case base
@@ -27,7 +27,7 @@ class Integer
# @overload to_s(base_number)
# @param [Fixnum] base_number Delegate to standard to_s
# @overload to_s(positional_chars)
- # @param [Array<#to_sym>] positional_chars
+ # @param [Array<Symbol, String, #to_sym>] positional_chars
# @return [String]
def to_s(base=10)
case base
View
24 lib/integer/base/singleton_class.rb
@@ -2,34 +2,34 @@ class Integer; module Base
class << self
- # @param [#to_str] str
- # @param [Array<#to_sym>] chars
+ # @param [String, #to_str] str
+ # @param [Array<Symbol, String, #to_sym>] positional_chars
# @return [Integer]
- def parse(str, chars)
+ def parse(str, positional_chars)
str = str.to_str.downcase
sign = parse_sign! str
abs = (
- case chars.length
+ case positional_chars.length
when 1
- parse_unary_abs str, chars.first
+ parse_unary_abs str, positional_chars.first
else
- parse_positional_abs str, chars
+ parse_positional_abs str, positional_chars
end
)
(sign == :-) ? -abs : abs
end
- # @param [#to_int] num
- # @param [Array<#to_sym>] chars
+ # @param [Integer, #to_int] num
+ # @param [Array<Symbol, String, #to_sym>] positional_chars
# @return [String]
- def string_for(num, chars)
- case chars.length
+ def string_for(num, positional_chars)
+ case positional_chars.length
when 1
- string_unary_for num, chars.first
+ string_unary_for num, positional_chars.first
else
- string_positional_for num, chars
+ string_positional_for num, positional_chars
end
end

0 comments on commit f65406a

Please sign in to comment.