Sha256: 0d9df852820eb1a7b7863c8a3f786e55e664cfb1752cd1c22a0bdc25c70e708e
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true # A grand staff is a group of staves for a single instrument, such as a piano. class HeadMusic::GrandStaff GRAND_STAVES = { piano: { instrument: :piano, staves: [ {clef: :treble_clef, for: :right_hand}, {clef: :bass_clef, for: :left_hand} ] }, organ: { instrument: :organ, staves: [ {clef: :treble_clef, for: :right_hand}, {clef: :bass_clef, for: :left_hand}, {clef: :bass_clef, for: :pedals} ] } }.freeze 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 attr_reader :identifier, :data def initialize(name) @identifier = HeadMusic::Utilities::HashKey.for(name) @data = GRAND_STAVES[identifier] end def instrument @instrument ||= HeadMusic::Instrument.get(data[:instrument]) end def staves @staves ||= data[:staves].map do |staff| HeadMusic::Staff.new(staff[:clef], instrument: instrument) end end def brace_staves_index_first 0 end def brace_staves_index_last 1 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
head_music-1.0.0 | lib/head_music/grand_staff.rb |
head_music-0.29.0 | lib/head_music/grand_staff.rb |
head_music-0.28.0 | lib/head_music/grand_staff.rb |