Class: Ting::Syllable
- Inherits:
-
Object
- Object
- Ting::Syllable
- Defined in:
- lib/ting/groundwork.rb
Overview
Combination of an initial and a final, a tone, and possible capitalization A tone of ‘nil’ means the tone is not specified
Instance Attribute Summary collapse
-
#capitalized ⇒ Object
(also: #capitalized?)
Returns the value of attribute capitalized.
-
#final ⇒ Object
Returns the value of attribute final.
-
#initial ⇒ Object
Returns the value of attribute initial.
-
#tone ⇒ Object
Returns the value of attribute tone.
Class Method Summary collapse
Instance Method Summary collapse
- #+(tone) ⇒ Object
- #==(other) ⇒ Object
-
#initialize(initial, final, tone = nil, capitalized = false) ⇒ Syllable
constructor
A new instance of Syllable.
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(initial, final, tone = nil, capitalized = false) ⇒ Syllable
Returns a new instance of Syllable.
90 91 92 93 94 95 |
# File 'lib/ting/groundwork.rb', line 90 def initialize(initial, final, tone = nil, capitalized = false) self.initial = initial self.final = final self.tone = tone self.capitalized = capitalized end |
Instance Attribute Details
#capitalized ⇒ Object Also known as: capitalized?
Returns the value of attribute capitalized.
88 89 90 |
# File 'lib/ting/groundwork.rb', line 88 def capitalized @capitalized end |
#final ⇒ Object
Returns the value of attribute final.
88 89 90 |
# File 'lib/ting/groundwork.rb', line 88 def final @final end |
#initial ⇒ Object
Returns the value of attribute initial.
88 89 90 |
# File 'lib/ting/groundwork.rb', line 88 def initial @initial end |
#tone ⇒ Object
Returns the value of attribute tone.
88 89 90 |
# File 'lib/ting/groundwork.rb', line 88 def tone @tone end |
Class Method Details
.illegal?(i, f) ⇒ Boolean
107 108 109 |
# File 'lib/ting/groundwork.rb', line 107 def self.illegal?(i,f) ILLEGAL_COMBINATIONS.any? {|in_gr, fin_gr| in_gr.include?(i) && fin_gr.include?(f)} end |
Instance Method Details
#+(tone) ⇒ Object
97 98 99 |
# File 'lib/ting/groundwork.rb', line 97 def +(tone) self.class.new(self.initial, self.final, tone, self.capitalized) end |
#==(other) ⇒ Object
113 114 115 116 117 118 |
# File 'lib/ting/groundwork.rb', line 113 def ==( other ) return false unless other.is_a? Syllable [ other.initial, other.final, other.tone, other.capitalized ] == [ self.initial, self.final, self.tone, self.capitalized ] end |
#inspect ⇒ Object Also known as: to_s
101 102 103 |
# File 'lib/ting/groundwork.rb', line 101 def inspect "<#{self.class.name} <initial=#{initial.name}, final=#{final.name}, tone=#{tone}#{', capitalized' if capitalized}>>" end |