Dealing with codes - phonetic_alphabet plugin (Ruby on Rails)
Most fonts are designed for readability of words, not complicated codes and recently, we've had to provide referreral codes to our partners so that we can track the applications that come from them. Instead of sufferring through referral codes being incorrectly provided because someone has confused an O for an 0 or a 1 for a l or even an I (see what I mean!), I created a plugin that turns any string into it's spoken version using the NATO phonetic alphabet.
To install this plugin in Ruby on Rails, just type the following from your application's root directory:
script/plugin install _
https://svn01.allmyfunds.com.au/svn/public/plugins/phonetic_alphabet
To use, see this except from the README file:
You can get the phonetic equivalent of a single character with PhoneticAlphabet[single_character]
or
You can convert a string to it's phonetic equivalent using the String#to_phonetic overridden method.
Example:
puts "hello world".to_phonetic
Outputs:
hotel echo lima lima oscar SPACE whiskey oscar romeo lima delta
You can also pass in a different separator:
Example:
puts "hello world".to_phonetic("-")
Outputs:
hotel-echo-lima-lima-oscar-SPACE-whiskey-oscar-romeo-lima-delta
Reader Comments