Module | Rufus::Mnemo |
In: |
lib/rufus/mnemo.rb
|
This module contains methods for converting plain integers (base 10) into words that are easier to read and remember.
For example, the equivalent of the (base 10) integer 1329724967 is "takeshimaya".
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 ruote Ruby workflow engine for generating ‘kawaii’ business process instance ids.
require 'rubygems' require 'rufus/mnemo' s = Rufus::Mnemo::from_integer 125704 puts s # => 'karasu' i = Rufus::Mnemo::to_integer s # => 125704
You can use Mnemo directly from the command line :
$ ruby mnemo.rb kotoba 141260 $ ruby mnemo.rb rubi 3432 $ ruby mnemo.rb 2455 nada
might be useful when used from some scripts.
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 ]).collect { |c, v| c + v }.concat(%w[ wa wo ya yo yu ]) |
SPECIAL | = | [ [ 'hu', 'fu' ], [ 'si', 'shi' ], [ 'ti', 'chi' ], [ 'tu', 'tsu' ], [ 'zi', 'tzu' ] |
NEG | = | 'wi' |
NEGATIVE | = | /^#{NEG}(.+)$/ |
from_integer | -> | to_string |
from_integer | -> | to_s |
from_integer | -> | from_i |
to_integer | -> | to_i |
to_integer | -> | from_string |
to_integer | -> | from_s |