lib/rufus/mnemo.rb in rufus-mnemo-1.2.1 vs lib/rufus/mnemo.rb in rufus-mnemo-1.2.2

- old
+ new

@@ -66,11 +66,11 @@ # # might be useful when used from some scripts. # module Mnemo - VERSION = '1.2.1' + VERSION = '1.2.2' SYL = %w[ b d g h j k m n p r s t z ].product(%w[ a e i o u @@ -93,18 +93,18 @@ # def self.from_integer(integer) return "#{NEG}#{from_integer(-integer)}" if integer < 0 - to_special(from_i(integer)) + to_special(_from_integer(integer)) end # Turns the given Mnemo word to its equivalent integer. # def self.to_integer(string) - to_i(from_special(string)) + _to_i(from_special(string)) end # Turns a simple syllable into the equivalent number. # For example Mnemo::to_number("fu") will yield 19. # @@ -163,11 +163,11 @@ def self.from_special(s) SPECIAL.inject(s) { |ss, (a, b)| ss.gsub(b, a) } end - def self.from_i(integer) + def self._from_integer(integer) # :nodoc: return '' if integer == 0 mod = integer % SYL.length rest = integer / SYL.length @@ -177,24 +177,31 @@ # mathn prevention from_i(rest) + SYL[mod] end - def self.to_i(s) + def self._to_i(s) # :nodoc: if s.length == 0 return 0 end if m = s.match(NEGATIVE) - return -1 * to_i(m[1]) + return -1 * _to_i(m[1]) end - SYL.length * to_i(s[0..-3]) + to_number(s[-2, 2]) + SYL.length * _to_i(s[0..-3]) + to_number(s[-2, 2]) end class << self - alias to_s from_i + + alias to_string from_integer + alias to_s from_integer + alias from_i from_integer + + alias to_i to_integer + alias from_string to_integer + alias from_s to_integer end end end #