Class: Phonology::Sound
- Inherits:
-
Object
- Object
- Phonology::Sound
- Includes:
- SoundBase
- Defined in:
- lib/phonology/sound.rb
Overview
A set of distinctive features
Instance Attribute Summary
Attributes included from SoundBase
#features, #hints, #orthography, #syllable
Class Method Summary collapse
-
.exists?(features) ⇒ Boolean
Does the group of features exist in human speech?.
Instance Method Summary collapse
-
#<<(*args) ⇒ Object
(also: #add)
Add a feature, replacing either the place or manner of articulation, or the height or backness.
-
#>>(*args) ⇒ Object
(also: #delete)
Remove a feature, and return self.
-
#add!(*args) ⇒ Object
Add a feature without replacing place or manner.
-
#codepoints ⇒ Object
Get the IPA codepoints for the sound, excluding any diacritics.
-
#exists? ⇒ Boolean
Does the sound exist?.
-
#initialize(*features) ⇒ Sound
constructor
A new instance of Sound.
Methods included from SoundBase
#backness, #coarticulated?, #height, #hint, #manner, #place, #place_groups, #sonority, #symbol
Constructor Details
#initialize(*features) ⇒ Sound
Returns a new instance of Sound.
116 117 118 119 120 121 122 |
# File 'lib/phonology/sound.rb', line 116 def initialize(*features) if features.first.kind_of?(String) self.features = Phonology.features_for(features.shift).clone else self.features = features.to_set end end |
Class Method Details
.exists?(features) ⇒ Boolean
Does the group of features exist in human speech?
112 113 114 |
# File 'lib/phonology/sound.rb', line 112 def self.exists?(features) !! Features::SETS[features] end |
Instance Method Details
#<<(*args) ⇒ Object Also known as: add
Add a feature, replacing either the place or manner of articulation, or the height or backness. Returns self.
131 132 133 134 135 136 137 |
# File 'lib/phonology/sound.rb', line 131 def <<(*args) args.to_a.flatten.each do |feature| features.subtract Features.set(feature).to_a add! feature end self end |
#>>(*args) ⇒ Object Also known as: delete
Remove a feature, and return self.
147 148 149 150 151 152 |
# File 'lib/phonology/sound.rb', line 147 def >>(*args) args.to_a.flatten.each do |feature| features.delete feature.to_sym end self end |
#add!(*args) ⇒ Object
Add a feature without replacing place or manner.
141 142 143 144 |
# File 'lib/phonology/sound.rb', line 141 def add!(*args) args.map {|a| features.add a.to_sym } self end |
#codepoints ⇒ Object
Get the IPA codepoints for the sound, excluding any diacritics.
125 126 127 |
# File 'lib/phonology/sound.rb', line 125 def codepoints Phonology.sounds.codepoints(features) end |
#exists? ⇒ Boolean
Does the sound exist?
156 157 158 |
# File 'lib/phonology/sound.rb', line 156 def exists? self.class.exists?(features) end |