class HeadMusic::GrandStaff

A grand staff is a group of staves for a single instrument, such as a piano.

Constants

GRAND_STAVES

Attributes

data[R]
identifier[R]

Public Class Methods

get(name) click to toggle source
# File lib/head_music/grand_staff.rb, line 23
def self.get(name)
  @grand_staves ||= {}
  hash_key = HeadMusic::Utilities::HashKey.for(name)
  return nil unless GRAND_STAVES.key?(hash_key)

  @grand_staves[hash_key] ||= new(hash_key)
end
new(name) click to toggle source
# File lib/head_music/grand_staff.rb, line 33
def initialize(name)
  @identifier = HeadMusic::Utilities::HashKey.for(name)
  @data = GRAND_STAVES[identifier]
end

Public Instance Methods

brace_staves_index_first() click to toggle source
# File lib/head_music/grand_staff.rb, line 49
def brace_staves_index_first
  0
end
brace_staves_index_last() click to toggle source
# File lib/head_music/grand_staff.rb, line 53
def brace_staves_index_last
  1
end
instrument() click to toggle source
# File lib/head_music/grand_staff.rb, line 38
def instrument
  @instrument ||= HeadMusic::Instrument.get(data[:instrument])
end
staves() click to toggle source
# File lib/head_music/grand_staff.rb, line 42
def staves
  @staves ||=
    data[:staves].map do |staff|
      HeadMusic::Staff.new(staff[:clef], instrument: instrument)
    end
end