Sha256: bc36303ab01a315f3aaf0c48554f4fbfe316966dbd5ec584c6bf4545cc9c7c5b

Contents?: true

Size: 602 Bytes

Versions: 5

Compression:

Stored size: 602 Bytes

Contents

# coding: utf-8

module Ting
  module Tones
    class Marks < Tone
      class <<self

        GLYPHS=['˙', '', 'ˊ', 'ˇ', 'ˋ']

        def add_tone(syll,tone)
          syll + GLYPHS[normalize(tone) % 5]
        end

        def peek_tone(syll)
          case syll
          when /ˊ/
            2
          when /ˇ/
            3
          when /ˋ/
            4
          when /˙/
            NEUTRAL_TONE
          else 
            1
          end
        end

        def pop_tone(syll)
          [ peek_tone(syll), syll[/\A[^#{GLYPHS.join}]+/] ]
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ting-0.12.0 lib/ting/tones/marks.rb
ting-0.11.0 lib/ting/tones/marks.rb
ting-0.10.0 lib/ting/tones/marks.rb
ting-0.9.0 lib/ting/tones/marks.rb
ting-0.3.0 lib/ting/tones/marks.rb