Class: Musa::MusicXML::Builder::Internal::Measure

Inherits:
Object
  • Object
show all
Extended by:
Extension::AttributeBuilder
Includes:
Extension::With, Helper::ToXML
Defined in:
lib/musa-dsl/musicxml/builder/measure.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Extension::AttributeBuilder

attr_complex_adder_to_array, attr_complex_adder_to_custom, attr_complex_builder, attr_simple_builder, attr_tuple_adder_to_array, attr_tuple_adder_to_hash, attr_tuple_builder

Methods included from Helper::ToXML

#to_xml

Methods included from Extension::With

#with

Constructor Details

#initialize(number, divisions: nil, key_cancel: nil, key_fifths: nil, key_mode: nil, time_senza_misura: nil, time_beats: nil, time_beat_type: nil, clef_sign: nil, clef_line: nil, clef_octave_change: nil, &block) ⇒ Measure

Returns a new instance of Measure.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/musa-dsl/musicxml/builder/measure.rb', line 22

def initialize(number, divisions: nil,
               key_cancel: nil, key_fifths: nil, key_mode: nil,
               time_senza_misura: nil, time_beats: nil, time_beat_type: nil,
               clef_sign: nil, clef_line: nil, clef_octave_change: nil,
               &block)

  @number = number
  @elements = []

  @attributes = []

  if divisions ||
      key_cancel || key_fifths || key_mode ||
      time_senza_misura || time_beats || time_beat_type ||
      clef_sign || clef_line || clef_octave_change

    add_attributes divisions: divisions,
                   key_cancel: key_cancel, key_fifths: key_fifths, key_mode: key_mode,
                   time_senza_misura: time_senza_misura, time_beats: time_beats, time_beat_type: time_beat_type,
                   clef_sign: clef_sign, clef_line: clef_line, clef_octave_change: clef_octave_change
  end

  with &block if block_given?
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



48
49
50
# File 'lib/musa-dsl/musicxml/builder/measure.rb', line 48

def elements
  @elements
end

#numberObject

Returns the value of attribute number.



47
48
49
# File 'lib/musa-dsl/musicxml/builder/measure.rb', line 47

def number
  @number
end

Instance Method Details

#_to_xml(io, indent:, tabs:) ⇒ Object



124
125
126
127
128
129
130
131
132
# File 'lib/musa-dsl/musicxml/builder/measure.rb', line 124

def _to_xml(io, indent:, tabs:)
  io.puts "#{tabs}<measure number=\"#{@number.to_i}\">"

  @elements.each do |element|
    element.to_xml(io, indent: indent + 1)
  end

  io.puts "#{tabs}</measure>"
end