Class: HeadMusic::GrandStaff
- Inherits:
-
Object
- Object
- HeadMusic::GrandStaff
- Defined in:
- lib/head_music/grand_staff.rb
Overview
A grand staff is a group of staves for a single instrument, such as a piano.
Constant Summary collapse
- 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
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Class Method Summary collapse
Instance Method Summary collapse
- #brace_staves_index_first ⇒ Object
- #brace_staves_index_last ⇒ Object
-
#initialize(name) ⇒ GrandStaff
constructor
A new instance of GrandStaff.
- #instrument ⇒ Object
- #staves ⇒ Object
Constructor Details
#initialize(name) ⇒ GrandStaff
Returns a new instance of GrandStaff.
33 34 35 36 |
# File 'lib/head_music/grand_staff.rb', line 33 def initialize(name) @identifier = HeadMusic::Utilities::HashKey.for(name) @data = GRAND_STAVES[identifier] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
31 32 33 |
# File 'lib/head_music/grand_staff.rb', line 31 def data @data end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
31 32 33 |
# File 'lib/head_music/grand_staff.rb', line 31 def identifier @identifier end |
Class Method Details
.get(name) ⇒ Object
23 24 25 26 27 28 29 |
# 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 |
Instance Method Details
#brace_staves_index_first ⇒ Object
49 50 51 |
# File 'lib/head_music/grand_staff.rb', line 49 def brace_staves_index_first 0 end |
#brace_staves_index_last ⇒ Object
53 54 55 |
# File 'lib/head_music/grand_staff.rb', line 53 def brace_staves_index_last 1 end |
#instrument ⇒ Object
38 39 40 |
# File 'lib/head_music/grand_staff.rb', line 38 def instrument @instrument ||= HeadMusic::Instrument.get(data[:instrument]) end |