module PinYin
Constants
- VERSION
Attributes
backend[RW]
Public Class Methods
abbr(str, except_lead=false, except_english=true)
click to toggle source
# File lib/ruby-pinyin.rb, line 20 def abbr(str, except_lead=false, except_english=true) result = "" of_string(str).each_with_index do |word, i| w = (except_lead && i == 0) || (except_english && word.english?) ? word : word[0] result << w end result end
override_files=(files)
click to toggle source
# File lib/ruby-pinyin.rb, line 33 def override_files=(files) klass = backend ? backend.class : PinYin::Backend::MMSeg self.backend = klass.new files end
permlink(str, sep='-')
click to toggle source
# File lib/ruby-pinyin.rb, line 16 def permlink(str, sep='-') of_string(str).join(sep) end
romanize(str, tone=nil, include_punctuations=false)
click to toggle source
# File lib/ruby-pinyin.rb, line 11 def romanize(str, tone=nil, include_punctuations=false) backend.romanize(str, tone, include_punctuations) end
Also aliased as: of_string
sentence(str, tone=nil)
click to toggle source
# File lib/ruby-pinyin.rb, line 29 def sentence(str, tone=nil) of_string(str, tone, true).join(' ') end