Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string_to_pinyin.rb
Instance Method Summary collapse
Instance Method Details
#to_pinyin ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/string_to_pinyin.rb', line 7 def idx_file_path = File.('../../data/idx99-tone.txt',__FILE__) result = "" self.scan(/./) do |char| match = %x[grep -m1 '^#{char}' #{idx_file_path}] if match.empty? result = result + char else = match.gsub("\n","").split("\t")[1] result = result + + " " end end return result.rstrip end |