Class: Pinyin::Writer

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

Instance Method Summary collapse

Constructor Details

#initialize(conv, tone) ⇒ Writer

Returns a new instance of Writer.



47
48
49
50
# File 'lib/pinyin.rb', line 47

def initialize(conv, tone)
  @conv = conv.to_s
  @tone = Tones.const_get tone.to_s.camelcase
end

Instance Method Details

#unparse(py) ⇒ Object Also known as: <<



52
53
54
55
56
57
58
59
# File 'lib/pinyin.rb', line 52

def unparse(py)
  conv=lambda {|syll| @tone.add_tone(Conversions.unparse(@conv,syll),syll.tone)}
  if py.respond_to? :map
    py.map(&conv).join(' ')
  else
    conv.call(py)
  end
end