Class: MusicalScore::Note::TimeModification
- Inherits:
-
ElementBase
- Object
- ElementBase
- MusicalScore::Note::TimeModification
- Includes:
- Contracts
- Defined in:
- lib/musical_score/note/time_modification.rb
Instance Attribute Summary collapse
-
#actual_notes ⇒ Object
readonly
Returns the value of attribute actual_notes.
-
#normal_notes ⇒ Object
readonly
Returns the value of attribute normal_notes.
Class Method Summary collapse
Instance Method Summary collapse
- #export_xml ⇒ Object
-
#initialize(actual_notes, normal_notes) ⇒ TimeModification
constructor
A new instance of TimeModification.
Constructor Details
#initialize(actual_notes, normal_notes) ⇒ TimeModification
Returns a new instance of TimeModification.
9 10 11 12 |
# File 'lib/musical_score/note/time_modification.rb', line 9 def initialize(actual_notes, normal_notes) @actual_notes = actual_notes @normal_notes = normal_notes end |
Instance Attribute Details
#actual_notes ⇒ Object (readonly)
Returns the value of attribute actual_notes.
6 7 8 |
# File 'lib/musical_score/note/time_modification.rb', line 6 def actual_notes @actual_notes end |
#normal_notes ⇒ Object (readonly)
Returns the value of attribute normal_notes.
6 7 8 |
# File 'lib/musical_score/note/time_modification.rb', line 6 def normal_notes @normal_notes end |
Class Method Details
.create_by_hash(doc) ⇒ Object
22 23 24 25 26 |
# File 'lib/musical_score/note/time_modification.rb', line 22 def self.create_by_hash(doc) actual_notes = doc["actual-notes"][0].to_i normal_notes = doc["normal-notes"][0].to_i return MusicalScore::Note::TimeModification.new(actual_notes, normal_notes) end |
.create_by_xml(xml_doc) ⇒ Object
15 16 17 18 19 |
# File 'lib/musical_score/note/time_modification.rb', line 15 def self.create_by_xml(xml_doc) actual_notes = xml_doc.elements["actual-notes"].text.to_i normal_notes = xml_doc.elements["normal-notes"].text.to_i return MusicalScore::Note::TimeModification.new(actual_notes, normal_notes) end |
Instance Method Details
#export_xml ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/musical_score/note/time_modification.rb', line 28 def export_xml time_modification_element = REXML::Element.new('time-modification') actual_notes_element = REXML::Element.new('actual-notes').add_text(@actual_notes.to_s) normal_notes_element = REXML::Element.new('normal-notes').add_text(@normal_notes.to_s) time_modification_element.add_element(actual_notes_element) time_modification_element.add_element(normal_notes_element) return time_modification_element end |