Class: Clef::Notation::Lyric
- Inherits:
-
Object
- Object
- Clef::Notation::Lyric
- Defined in:
- lib/clef/notation/lyric.rb
Constant Summary collapse
- HYPHEN =
"--"- EXTENDER =
"_"
Instance Attribute Summary collapse
-
#syllables ⇒ Object
readonly
Returns the value of attribute syllables.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#voice_id ⇒ Object
readonly
Returns the value of attribute voice_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(voice_id, text) ⇒ Lyric
constructor
A new instance of Lyric.
- #note_slot_count ⇒ Integer
Constructor Details
#initialize(voice_id, text) ⇒ Lyric
Returns a new instance of Lyric.
13 14 15 16 17 18 19 |
# File 'lib/clef/notation/lyric.rb', line 13 def initialize(voice_id, text) raise ArgumentError, "text must be String" unless text.is_a?(String) @voice_id = voice_id @text = text @syllables = parse_syllables(text) end |
Instance Attribute Details
#syllables ⇒ Object (readonly)
Returns the value of attribute syllables.
9 10 11 |
# File 'lib/clef/notation/lyric.rb', line 9 def syllables @syllables end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
9 10 11 |
# File 'lib/clef/notation/lyric.rb', line 9 def text @text end |
#voice_id ⇒ Object (readonly)
Returns the value of attribute voice_id.
9 10 11 |
# File 'lib/clef/notation/lyric.rb', line 9 def voice_id @voice_id end |
Class Method Details
.extender?(syllable) ⇒ Boolean
40 41 42 |
# File 'lib/clef/notation/lyric.rb', line 40 def self.extender?(syllable) syllable == EXTENDER end |
.hyphen?(syllable) ⇒ Boolean
34 35 36 |
# File 'lib/clef/notation/lyric.rb', line 34 def self.hyphen?(syllable) syllable == HYPHEN end |
.note_syllable?(syllable) ⇒ Boolean
28 29 30 |
# File 'lib/clef/notation/lyric.rb', line 28 def self.note_syllable?(syllable) syllable != HYPHEN end |
Instance Method Details
#note_slot_count ⇒ Integer
22 23 24 |
# File 'lib/clef/notation/lyric.rb', line 22 def note_slot_count syllables.count { |syllable| self.class.note_syllable?(syllable) } end |