Class: Musa::MusicXML::Builder::Internal::Time
- Inherits:
-
Object
- Object
- Musa::MusicXML::Builder::Internal::Time
- Includes:
- Helper::ToXML
- Defined in:
- lib/musa-dsl/musicxml/builder/attributes.rb
Instance Attribute Summary collapse
-
#beats ⇒ Object
readonly
Returns the value of attribute beats.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#senza_misura ⇒ Object
Returns the value of attribute senza_misura.
Instance Method Summary collapse
- #_to_xml(io, indent:, tabs:) ⇒ Object
- #add_beats(beats:, beat_type:) ⇒ Object
-
#initialize(number = nil, senza_misura: nil, beats: nil, beat_type: nil) ⇒ Time
constructor
A new instance of Time.
Methods included from Helper::ToXML
Constructor Details
#initialize(number = nil, senza_misura: nil, beats: nil, beat_type: nil) ⇒ Time
Returns a new instance of Time.
44 45 46 47 48 49 50 51 |
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 44 def initialize(number = nil, senza_misura: nil, beats: nil, beat_type: nil) @number = number @senza_misura = senza_misura unless beats && beat_type @beats = [] add_beats beats: beats, beat_type: beat_type if beats && beat_type end |
Instance Attribute Details
#beats ⇒ Object (readonly)
Returns the value of attribute beats.
55 56 57 |
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 55 def beats @beats end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
53 54 55 |
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 53 def number @number end |
#senza_misura ⇒ Object
Returns the value of attribute senza_misura.
54 55 56 |
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 54 def senza_misura @senza_misura end |
Instance Method Details
#_to_xml(io, indent:, tabs:) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 61 def _to_xml(io, indent:, tabs:) io.puts "#{tabs}<time#{" number=\"#{@number.to_i}\"" if @number}>" io.puts "#{tabs}\t<senza-misura>#{@senza_misura}</senza-misura>" if @senza_misura @beats.each do |beats| io.puts "#{tabs}\t<beats>#{beats[:beats].to_i}</beats>" io.puts "#{tabs}\t<beat-type>#{beats[:beat_type].to_i}</beat-type>" end io.puts "#{tabs}</time>" end |
#add_beats(beats:, beat_type:) ⇒ Object
57 58 59 |
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 57 def add_beats(beats:, beat_type:) @beats << { beats: beats, beat_type: beat_type } end |