Sha256: 81e390fd4b5c5a42a91b00623463f9247dc12c01318bc02ed9c65f51e9aa59a2
Contents?: true
Size: 464 Bytes
Versions: 2
Compression:
Stored size: 464 Bytes
Contents
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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ting-0.2.1 | lib/ting/string.rb |
ting-0.2.0 | lib/ting/string.rb |