Class: MusicalScore::Note::Lyric
- Inherits:
-
ElementBase
- Object
- ElementBase
- MusicalScore::Note::Lyric
- Includes:
- Contracts
- Defined in:
- lib/musical_score/note/lyric.rb
Constant Summary collapse
- @@syllabic =
%i(single begin end middle)
Instance Attribute Summary collapse
-
#is_extend ⇒ Object
Returns the value of attribute is_extend.
-
#syllabic ⇒ Object
Returns the value of attribute syllabic.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #export_xml(number) ⇒ Object
-
#initialize(text, syllabic, is_extend = false) ⇒ Lyric
constructor
A new instance of Lyric.
Constructor Details
#initialize(text, syllabic, is_extend = false) ⇒ Lyric
Returns a new instance of Lyric.
15 16 17 18 19 |
# File 'lib/musical_score/note/lyric.rb', line 15 def initialize(text, syllabic, is_extend = false) @text = text @syllabic = syllabic @is_extend = is_extend end |
Instance Attribute Details
#is_extend ⇒ Object
Returns the value of attribute is_extend.
7 8 9 |
# File 'lib/musical_score/note/lyric.rb', line 7 def is_extend @is_extend end |
#syllabic ⇒ Object
Returns the value of attribute syllabic.
7 8 9 |
# File 'lib/musical_score/note/lyric.rb', line 7 def syllabic @syllabic end |
#text ⇒ Object
Returns the value of attribute text.
7 8 9 |
# File 'lib/musical_score/note/lyric.rb', line 7 def text @text end |
Class Method Details
.create_by_hash(doc) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/musical_score/note/lyric.rb', line 29 def self.create_by_hash(doc) syllabic = doc.has_key?("syllabic") ? doc["syllabic"][0].to_sym : nil text = doc["text"][0] is_extend = doc.has_key?("extend") return MusicalScore::Note::Lyric.new(text, syllabic, is_extend) end |
.create_by_xml(xml_doc) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/musical_score/note/lyric.rb', line 21 def self.create_by_xml(xml_doc) syllabic = xml_doc.elements["syllabic"] ? xml_doc.elements["syllabic"].text.to_sym : nil text = xml_doc.elements["text"].text is_extend = xml_doc.elements["extend"] ? true : false return MusicalScore::Note::Lyric.new(text, syllabic, is_extend) end |
Instance Method Details
#export_xml(number) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/musical_score/note/lyric.rb', line 36 def export_xml(number) lyric_element = REXML::Element.new('lyric') lyric_element.add_attribute('number', number.to_s) text_element = REXML::Element.new('text').add_text(@text.to_s) if (@syllabic) syllabic_element = REXML::Element.new('syllabic').add_text(@syllabic.to_s) lyric_element.add_element(syllabic_element) end lyric_element.add_element(text_element) return lyric_element end |