Class: Ting::Tones::Marks

Inherits:
Ting::Tone show all
Defined in:
lib/ting/tones/marks.rb

Constant Summary collapse

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

Constants inherited from Ting::Tone

Ting::Tone::MAX_TONE, Ting::Tone::VALID_TONES

Class Method Summary collapse

Class Method Details

.add_tone(syll, tone) ⇒ Object



10
11
12
# File 'lib/ting/tones/marks.rb', line 10

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

.peek_tone(syll) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ting/tones/marks.rb', line 14

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

.pop_tone(syll) ⇒ Object



29
30
31
# File 'lib/ting/tones/marks.rb', line 29

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