Class: Ting::Tones::Supernum

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

Constant Summary collapse

GLYPHS =

⁰ for neutral tone?

['', '¹', '²', '³', '',]

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/supernum.rb', line 10

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

.peek_tone(syll) ⇒ Object



14
15
16
17
18
19
# File 'lib/ting/tones/supernum.rb', line 14

def peek_tone(syll)
  if t = GLYPHS.index(syll.chars.last)
    return t
  end
  return NEUTRAL_TONE
end

.pop_tone(syll) ⇒ Object



21
22
23
# File 'lib/ting/tones/supernum.rb', line 21

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