Class: Ting::Reader
Instance Method Summary collapse
-
#initialize(conv, tone) ⇒ Reader
constructor
A new instance of Reader.
- #parse(str) ⇒ Object (also: #<<, #call)
Methods included from Procable
Constructor Details
Instance Method Details
#parse(str) ⇒ Object Also known as: <<, call
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ting/reader.rb', line 10 def parse(str) Conversions.tokenize(str).map do |token, pos| tone, syll = @tone.pop_tone(token) tsyll = Conversions.parse(@conv, syll) ini, fin = tsyll.initial, tsyll.final unless tone && fin && ini raise ParseError.new(token, pos),"Illegal syllable <#{token}> in input <#{str}> at position #{pos}." end tsyll + tone end rescue Object => e raise ParseError.new(str, 0, e), "Parsing of #{str.inspect} failed : #{e}" end |