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

- old
+ new

@@ -1,7 +1,7 @@ #-- -# Copyright (c) 2007-2011, John Mettraux, jmettraux@gmail.com +# Copyright (c) 2007-2012, John Mettraux, jmettraux@gmail.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -36,12 +36,12 @@ # Mnemo uses 70 of the syllables of the Japanese language, it is thus # a base 10 to base 70 converter. # # Mnemo is meant to be used for generating human readable (or more # easily rememberable) identifiers. Its first usage is within the - # OpenWFEru Ruby workflow and bpm engine for generating 'kawaii' - # business process instance ids. + # ruote Ruby workflow engine for generating 'kawaii' business process + # instance ids. # # require 'rubygems' # require 'rufus/mnemo' # # s = Rufus::Mnemo::from_integer 125704 @@ -66,11 +66,11 @@ # # might be useful when used from some scripts. # module Mnemo - VERSION = '1.2.2' + VERSION = '1.2.3' SYL = %w[ b d g h j k m n p r s t z ].product(%w[ a e i o u @@ -120,14 +120,13 @@ # For example, "tsunashima" will be split into # [ "tsu", "na", "shi", "ma" ] # def self.split(word) - word = from_special(word) - a = string_split(word) - - a_to_special(a) + a_to_special( + string_split( + from_special(word))) end # Returns if the string is a Mnemo word, like "fugu" or # "toriyamanobashi". # @@ -150,10 +149,10 @@ string_split(s[2..-1], result) end def self.a_to_special(a) - a.collect { |syl| SPECIAL.find { |aa, bb| syl == bb } || syl } + a.collect { |syl| (SPECIAL.assoc(syl) || [ nil, syl ])[1] } end def self.to_special(s) SPECIAL.inject(s) { |ss, (a, b)| ss.gsub(a, b) }