Class: HeadMusic::Instrument::PitchConfiguration
- Inherits:
-
Object
- Object
- HeadMusic::Instrument::PitchConfiguration
- Defined in:
- lib/head_music/instrument/pitch_configuration.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #default? ⇒ Boolean
- #default_staff_configuration ⇒ Object
- #fundamental_pitch_spelling ⇒ Object
-
#initialize(key, attributes = {}) ⇒ PitchConfiguration
constructor
A new instance of PitchConfiguration.
- #staff_configurations ⇒ Object
Constructor Details
#initialize(key, attributes = {}) ⇒ PitchConfiguration
Returns a new instance of PitchConfiguration.
4 5 6 7 |
# File 'lib/head_music/instrument/pitch_configuration.rb', line 4 def initialize(key, attributes = {}) @key = key.to_s.to_sym @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
2 3 4 |
# File 'lib/head_music/instrument/pitch_configuration.rb', line 2 def attributes @attributes end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
2 3 4 |
# File 'lib/head_music/instrument/pitch_configuration.rb', line 2 def key @key end |
Instance Method Details
#default? ⇒ Boolean
27 28 29 |
# File 'lib/head_music/instrument/pitch_configuration.rb', line 27 def default? key.to_s == "default" end |
#default_staff_configuration ⇒ Object
31 32 33 34 |
# File 'lib/head_music/instrument/pitch_configuration.rb', line 31 def default_staff_configuration @default_staff_configuration ||= staff_configurations.find(&:default?) || staff_configurations.first end |
#fundamental_pitch_spelling ⇒ Object
9 10 11 12 13 14 |
# File 'lib/head_music/instrument/pitch_configuration.rb', line 9 def fundamental_pitch_spelling return unless attributes["fundamental_pitch_spelling"].to_s != "" @fundamental_pitch_spelling ||= HeadMusic::Spelling.get(attributes["fundamental_pitch_spelling"]) end |
#staff_configurations ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/head_music/instrument/pitch_configuration.rb', line 16 def staff_configurations @staff_configurations ||= (attributes["staff_configurations"] || {}).map do |key, list| HeadMusic::Instrument::StaffConfiguration.new( key: key, pitch_configuration: self, list: list ) end end |