Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/pinyin/string.rb,
lib/pinyin/support.rb

Instance Method Summary collapse

Instance Method Details

#bpmfObject



8
9
10
11
12
13
# File 'lib/pinyin/string.rb', line 8

def bpmf
  self.gsub('u:','ü').scan(/[A-Za-züÜ]{1,5}\d/).map do |m|
    Pinyin.ZhuyinWriter(:marks) << 
      (Pinyin.HanyuReader(:numbers) << m.downcase)
  end.join(' ')
end

#charsObject



2
3
4
# File 'lib/pinyin/support.rb', line 2

def chars
  self.unpack('U*').map{|c| [c].pack('U')}
end

#pretty_tonesObject



2
3
4
5
6
# File 'lib/pinyin/string.rb', line 2

def pretty_tones
  self.gsub('u:','ü').gsub(/[A-Za-züÜ]{1,5}\d/) do |m|
    Pinyin.HanyuWriter(:accents) << Pinyin.HanyuReader(:numbers).parse(m.downcase)
  end
end