Class: Musa::MusicXML::Builder::Internal::Tuplet

Inherits:
Object
  • Object
show all
Includes:
Helper, ToXML
Defined in:
lib/musa-dsl/musicxml/builder/note-complexities.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, number: nil, bracket: nil, show_number: nil, show_type: nil, actual_number: nil, actual_type: nil, actual_dots: nil, normal_number: nil, normal_type: nil, normal_dots: nil) ⇒ Tuplet

start / stop



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 42

def initialize(type:, # start / stop
               number: nil, # number
               bracket: nil, # true
               show_number: nil, # actual / both / none
               show_type: nil, # actual / both / none
               actual_number: nil, # number
               actual_type: nil, # quarter / eigth / ...
               actual_dots: nil, # number,
               normal_number: nil, # number
               normal_type: nil, # quarter / eigth / ...
               normal_dots: nil) # number

  @type = type
  @number = number
  @bracket = bracket
  @show_number = show_number
  @show_type = show_type
  @actual_number = actual_number
  @actual_type = actual_type
  @actual_dots = actual_dots
  @normal_number = normal_number
  @normal_type = normal_type
  @normal_dots = normal_dots
end

Instance Attribute Details

#actual_dotsObject

Returns the value of attribute actual_dots.



68
69
70
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 68

def actual_dots
  @actual_dots
end

#actual_numberObject

Returns the value of attribute actual_number.



68
69
70
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 68

def actual_number
  @actual_number
end

#actual_typeObject

Returns the value of attribute actual_type.



68
69
70
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 68

def actual_type
  @actual_type
end

#bracketObject

Returns the value of attribute bracket.



67
68
69
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 67

def bracket
  @bracket
end

#normal_dotsObject

Returns the value of attribute normal_dots.



69
70
71
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 69

def normal_dots
  @normal_dots
end

#normal_numberObject

Returns the value of attribute normal_number.



69
70
71
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 69

def normal_number
  @normal_number
end

#normal_typeObject

Returns the value of attribute normal_type.



69
70
71
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 69

def normal_type
  @normal_type
end

#numberObject

Returns the value of attribute number.



67
68
69
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 67

def number
  @number
end

#show_numberObject

Returns the value of attribute show_number.



67
68
69
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 67

def show_number
  @show_number
end

#show_typeObject

Returns the value of attribute show_type.



67
68
69
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 67

def show_type
  @show_type
end

#typeObject

Returns the value of attribute type.



67
68
69
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 67

def type
  @type
end

Instance Method Details

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



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/musa-dsl/musicxml/builder/note-complexities.rb', line 71

def _to_xml(io, indent:, tabs:)
  io.puts "#{tabs}<tuplet type=\"#{@type}\"" \
"#{decode_bool_or_string_attribute(@number&.to_i, 'number')}" \
"#{decode_bool_or_string_attribute(@bracket, 'bracket', 'yes', 'no')}" \
"#{decode_bool_or_string_attribute(@show_number, 'show-number')}" \
"#{decode_bool_or_string_attribute(@show_type, 'show-type')}" \
">"

  if @actual_number || @actual_type || @actual_dots
    io.puts "#{tabs}\t<tuplet-actual>"

    io.puts "#{tabs}\t\t<tuplet-number>#{@actual_number.to_i}</tuplet-number>" if @actual_number
    io.puts "#{tabs}\t\t<tuplet-type>#{@actual_type}</tuplet-type>" if @actual_type

    @actual_dots&.times do
      io.puts "#{tabs}\t\t<tuplet-dot />"
    end

    io.puts "#{tabs}\t</tuplet-actual>"
  end

  if @normal_number || @normal_type || @normal_dots
    io.puts "#{tabs}\t<tuplet-normal>"

    io.puts "#{tabs}\t\t<tuplet-number>#{@normal_number.to_i}</tuplet-number>" if @normal_number
    io.puts "#{tabs}\t\t<tuplet-type>#{@normal_type}</tuplet-type>" if @normal_type

    @normal_dots&.times do
      io.puts "#{tabs}\t\t<tuplet-dot />"
    end

    io.puts "#{tabs}\t</tuplet-normal>"
  end

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