Module: PinYin::Util
Constant Summary collapse
- ASCIIMapping =
{ 'üē' => ['ue', 1], 'üé' => ['ue', 2], 'üě' => ['ue', 3], 'üè' => ['ue', 4], 'ā' => ['a', 1], 'ē' => ['e', 1], 'ī' => ['i', 1], 'ō' => ['o', 1], 'ū' => ['u', 1], 'ǖ' => ['v', 1], 'á' => ['a', 2], 'é' => ['e', 2], 'í' => ['i', 2], 'ó' => ['o', 2], 'ú' => ['u', 2], 'ǘ' => ['v', 2], 'ǎ' => ['a', 3], 'ě' => ['e', 3], 'ǐ' => ['i', 3], 'ǒ' => ['o', 3], 'ǔ' => ['u', 3], 'ǚ' => ['v', 3], 'à' => ['a', 4], 'è' => ['e', 4], 'ì' => ['i', 4], 'ò' => ['o', 4], 'ù' => ['u', 4], 'ǜ' => ['v', 4] }
Instance Method Summary collapse
Instance Method Details
#to_ascii(reading, with_tone = true) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby-pinyin/util.rb', line 15 def to_ascii(reading, with_tone=true) ASCIIMapping.each do |char, (ascii, tone)| if reading.include? char if with_tone return reading.sub(char, ascii).concat(tone.to_s) else return reading.sub(char, ascii) end end end reading end |