Class: Phonology::Syllable Abstract
- Inherits:
-
Object
- Object
- Phonology::Syllable
- Defined in:
- lib/phonology/syllable.rb
Overview
This class is abstract.
Instance Attribute Summary collapse
-
#coda ⇒ Object
Returns the value of attribute coda.
-
#nucleus ⇒ Object
Returns the value of attribute nucleus.
-
#onset ⇒ Object
Returns the value of attribute onset.
-
#stress ⇒ Object
Returns the value of attribute stress.
Instance Method Summary collapse
- #<<(sound) ⇒ Object (also: #add)
- #coda_wants?(sound) ⇒ Boolean
- #empty? ⇒ Boolean
-
#initialize(sound = nil) ⇒ Syllable
constructor
A new instance of Syllable.
- #nucleus_wants?(sound) ⇒ Boolean
- #onset_wants?(sound) ⇒ Boolean
- #rime ⇒ Object
- #to_a ⇒ Object
- #to_s(show_stress = true) ⇒ Object
- #valid? ⇒ Boolean
- #wants?(sound) ⇒ Boolean
Constructor Details
#initialize(sound = nil) ⇒ Syllable
Returns a new instance of Syllable.
7 8 9 10 11 12 |
# File 'lib/phonology/syllable.rb', line 7 def initialize(sound = nil) @onset = ::Phonology::SoundSequence.new @nucleus = ::Phonology::SoundSequence.new @coda = ::Phonology::SoundSequence.new add sound if sound end |
Instance Attribute Details
#coda ⇒ Object
Returns the value of attribute coda.
5 6 7 |
# File 'lib/phonology/syllable.rb', line 5 def coda @coda end |
#nucleus ⇒ Object
Returns the value of attribute nucleus.
5 6 7 |
# File 'lib/phonology/syllable.rb', line 5 def nucleus @nucleus end |
#onset ⇒ Object
Returns the value of attribute onset.
5 6 7 |
# File 'lib/phonology/syllable.rb', line 5 def onset @onset end |
#stress ⇒ Object
Returns the value of attribute stress.
5 6 7 |
# File 'lib/phonology/syllable.rb', line 5 def stress @stress end |
Instance Method Details
#<<(sound) ⇒ Object Also known as: add
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/phonology/syllable.rb', line 46 def <<(sound) if onset_wants?(sound) @onset << sound elsif nucleus_wants?(sound) @nucleus << sound else @coda << sound end sound.syllable = self end |
#coda_wants?(sound) ⇒ Boolean
42 43 44 |
# File 'lib/phonology/syllable.rb', line 42 def coda_wants?(sound) raise NotImplementedError end |
#empty? ⇒ Boolean
58 59 60 |
# File 'lib/phonology/syllable.rb', line 58 def empty? onset.empty? && nucleus.empty? && coda.empty? end |
#nucleus_wants?(sound) ⇒ Boolean
38 39 40 |
# File 'lib/phonology/syllable.rb', line 38 def nucleus_wants?(sound) raise NotImplementedError end |
#onset_wants?(sound) ⇒ Boolean
34 35 36 |
# File 'lib/phonology/syllable.rb', line 34 def onset_wants?(sound) raise NotImplementedError end |
#rime ⇒ Object
22 23 24 |
# File 'lib/phonology/syllable.rb', line 22 def rime [nucleus, coda] end |
#to_a ⇒ Object
14 15 16 |
# File 'lib/phonology/syllable.rb', line 14 def to_a [onset.to_a, rime.map(&:to_a)].flatten end |
#to_s(show_stress = true) ⇒ Object
26 27 28 |
# File 'lib/phonology/syllable.rb', line 26 def to_s(show_stress = true) (show_stress && stress ? IPA.primary_stress : "") + to_a.map(&:symbol).join end |
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/phonology/syllable.rb', line 18 def valid? !nucleus.empty? end |
#wants?(sound) ⇒ Boolean
30 31 32 |
# File 'lib/phonology/syllable.rb', line 30 def wants?(sound) onset_wants?(sound) or nucleus_wants?(sound) or coda_wants?(sound) end |