Class: Musa::MusicXML::Builder::Internal::Key

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper::ToXML

#to_xml

Constructor Details

#initialize(number = nil, cancel: nil, fifths:, mode: nil) ⇒ Key

Returns a new instance of Key.



12
13
14
15
16
17
18
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 12

def initialize(number = nil, cancel: nil, fifths:, mode: nil)
  @number = number

  @cancel = cancel
  @fifths = fifths
  @mode = mode
end

Instance Attribute Details

#cancelObject

Returns the value of attribute cancel.



21
22
23
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 21

def cancel
  @cancel
end

#fifthsObject

Returns the value of attribute fifths.



21
22
23
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 21

def fifths
  @fifths
end

#modeObject

Returns the value of attribute mode.



21
22
23
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 21

def mode
  @mode
end

#numberObject (readonly)

Returns the value of attribute number.



20
21
22
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 20

def number
  @number
end

Instance Method Details

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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/musa-dsl/musicxml/builder/attributes.rb', line 23

def _to_xml(io, indent:, tabs:)
  io ||= StringIO.new
  indent ||= 0

  tabs = "\t" * indent

  io.puts "#{tabs}<key#{" number=\"#{@number.to_i}\"" if @number}>"

  io.puts "#{tabs}\t<cancel>#{@cancel}</cancel>" if @cancel
  io.puts "#{tabs}\t<fifths>#{@fifths.to_i}</fifths>"
  io.puts "#{tabs}\t<mode>#{@mode}</mode>"

  io.puts "#{tabs}</key>"

  io
end