Class: Phonology::Sound

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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?

Returns:

  • (Boolean)


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

#codepointsObject

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?

Returns:

  • (Boolean)


156
157
158
# File 'lib/phonology/sound.rb', line 156

def exists?
  self.class.exists?(features)
end