class Ting::Tone

Base class for Tone classes

Constants

MAX_TONE
VALID_TONES

Public Class Methods

add_tone(s,t) click to toggle source

Add a tone to a syllable

# File lib/ting/tones.rb, line 11
def add_tone(s,t)
  s
end
peek_tone(s) click to toggle source

Determine the tone of a syllable

# File lib/ting/tones.rb, line 16
def peek_tone(s)
  NEUTRAL_TONE
end
pop_tone(s) click to toggle source

Remove the tone from a syllable

# File lib/ting/tones.rb, line 21
def pop_tone(s)
  [NEUTRAL_TONE, s]
end

Private Class Methods

normalize(t) click to toggle source

Make sure the tone number is in the valid range. Neutral tone is always represented as NEUTRAL_TONE (5), and not 0.

# File lib/ting/tones.rb, line 28
def normalize(t)
  if VALID_TONES === t
    t
  else
    t %= MAX_TONE
    t = NEUTRAL_TONE if t == 0
  end
end