Sha256: 648969b10e640b158da1fed4f1d498d6cc8f22902b0c816a2283ccdf5eddf317

Contents?: true

Size: 1.12 KB

Versions: 26

Compression:

Stored size: 1.12 KB

Contents

class HeadMusic::GrandStaff
  GRAND_STAVES = {
    piano: {
      instrument: :piano,
      staves: [
        { clef: :treble, instrument: :piano },
        { clef: :bass, instrument: :piano }
      ]
    },
    organ: {
      instrument: :organ,
      staves: [
        { clef: :treble, instrument: :organ },
        { clef: :bass, instrument: :organ },
        { clef: :bass, instrument: :pedals }
      ]
    }
  }

  def self.get(name)
    @grand_staves ||= {}
    hash_key = HeadMusic::Utilities::HashKey.for(name)
    return nil unless GRAND_STAVES.keys.include?(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 ||= begin
      data[:staves].map { |staff|
        HeadMusic::Staff.new(staff[:clef], instrument: staff[:instrument] || instrument)
      }
    end
  end

  def brace_staves_index_first
    0
  end

  def brace_staves_index_last
    1
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
head_music-0.17.0 lib/head_music/grand_staff.rb
head_music-0.16.2 lib/head_music/grand_staff.rb
head_music-0.16.0 lib/head_music/grand_staff.rb
head_music-0.14.8 lib/head_music/grand_staff.rb
head_music-0.14.7 lib/head_music/grand_staff.rb
head_music-0.14.5 lib/head_music/grand_staff.rb
head_music-0.14.4 lib/head_music/grand_staff.rb
head_music-0.14.2 lib/head_music/grand_staff.rb
head_music-0.14.1 lib/head_music/grand_staff.rb
head_music-0.13.2 lib/head_music/grand_staff.rb
head_music-0.11.9 lib/head_music/grand_staff.rb
head_music-0.11.8 lib/head_music/grand_staff.rb
head_music-0.11.7 lib/head_music/grand_staff.rb
head_music-0.11.6 lib/head_music/grand_staff.rb
head_music-0.11.5 lib/head_music/grand_staff.rb
head_music-0.11.4 lib/head_music/grand_staff.rb
head_music-0.11.3 lib/head_music/grand_staff.rb
head_music-0.11.2 lib/head_music/grand_staff.rb
head_music-0.11.1 lib/head_music/grand_staff.rb
head_music-0.10.0 lib/head_music/grand_staff.rb