Permalink
Browse files

modify base method name

  • Loading branch information...
1 parent 011ee81 commit aa35e4fe0fa7d6c19e472bc058dec8e26068d559 @kachick committed Aug 21, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/integer/base/singleton_class.rb
@@ -26,14 +26,16 @@ def parse(str, chars)
# @param [#to_int] num
# @param [Array<#to_sym>] chars
# @return [String]
- def convert_to_string(num, chars)
+ def string_for(num, chars)
case chars.length
when 1
convert_to_string_unary num, chars.first
else
convert_to_string_positional num, chars
end
end
+
+ alias_method :convert_to_string, :string_for
private
@@ -118,7 +120,7 @@ def parse_unary_abs(str, char)
end
# @return [String]
- def convert_to_string_positional(num, chars)
+ def string_positional_for(num, chars)
chars = base_chars_for chars
int = num.to_int
base = chars.length
@@ -136,16 +138,20 @@ def convert_to_string_positional(num, chars)
s.insert 0, '-' if int < 0
}
end
+
+ alias_method :convert_to_string_positional, :string_positional_for
# @return [String]
- def convert_to_string_unary(num, char)
+ def string_unary_for(num, char)
char = unary_char_for char
int = num.to_int
(char.to_s * int.abs).tap {|s|
s.insert 0, '-' if int < 0
}
end
+
+ alias_method :convert_to_string_unary, :string_unary_for
end

0 comments on commit aa35e4f

Please sign in to comment.