Class: Ting::Tones::Numbers

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

Constant Summary

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



6
7
8
# File 'lib/ting/tones/numbers.rb', line 6

def add_tone(syll, tone)
  syll + normalize(tone).to_s
end

.peek_tone(syll) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/ting/tones/numbers.rb', line 10

def peek_tone(syll)
  if syll =~ /(\d)\Z/
    normalize Integer($1)
  else
    NEUTRAL_TONE
  end
end

.pop_tone(syll) ⇒ Object



18
19
20
# File 'lib/ting/tones/numbers.rb', line 18

def pop_tone(syll)
  [ peek_tone(syll), syll[/\A\D+/] ]
end