Sha256: ff6710615eb62dd9e8d1496f848f8d6e8dea4002f5b04b3ff410ea7fd2a12f69
Contents?: true
Size: 481 Bytes
Versions: 1
Compression:
Stored size: 481 Bytes
Contents
# coding: utf-8 class String PINYIN_CACHE={} def pretty_tones self.gsub('u:','ü').gsub(/[A-Za-züÜ]{1,5}\d/) do |m| m.downcase! PINYIN_CACHE[m] || PINYIN_CACHE[m]=(Ting.writer(:hanyu, :accents) << Ting.reader(:hanyu, :numbers).parse(m.downcase)) end end def bpmf self.gsub('u:','ü').scan(/[A-Za-züÜ]{1,5}\d/).map do |m| Ting.writer(:zhuyin, :marks) << (Ting.reader(:hanyu, :numbers) << m.downcase) end.join(' ') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ting-0.3.0 | lib/ting/string.rb |