Class: Ting::Syllable

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

Class Method Summary collapse

Instance Method Summary collapse

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

#capitalizedObject Also known as: capitalized?

Returns the value of attribute capitalized.



88
89
90
# File 'lib/ting/groundwork.rb', line 88

def capitalized
  @capitalized
end

#finalObject

Returns the value of attribute final.



88
89
90
# File 'lib/ting/groundwork.rb', line 88

def final
  @final
end

#initialObject

Returns the value of attribute initial.



88
89
90
# File 'lib/ting/groundwork.rb', line 88

def initial
  @initial
end

#toneObject

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

Returns:

  • (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

#inspectObject 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