Class: HeadMusic::Instrument::PitchVariant
- Inherits:
-
Object
- Object
- HeadMusic::Instrument::PitchVariant
- Defined in:
- lib/head_music/instrument/pitch_variant.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_scheme ⇒ Object
- #fundamental_pitch_spelling ⇒ Object
-
#initialize(key, attributes = {}) ⇒ PitchVariant
constructor
A new instance of PitchVariant.
- #staff_schemes ⇒ Object
Constructor Details
#initialize(key, attributes = {}) ⇒ PitchVariant
Returns a new instance of PitchVariant.
4 5 6 7 |
# File 'lib/head_music/instrument/pitch_variant.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_variant.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_variant.rb', line 2 def key @key end |
Instance Method Details
#default? ⇒ Boolean
27 28 29 |
# File 'lib/head_music/instrument/pitch_variant.rb', line 27 def default? key.to_s == "default" end |
#default_staff_scheme ⇒ Object
31 32 33 34 |
# File 'lib/head_music/instrument/pitch_variant.rb', line 31 def default_staff_scheme @default_staff_scheme ||= staff_schemes.find(&:default?) || staff_schemes.first end |
#fundamental_pitch_spelling ⇒ Object
9 10 11 12 13 14 |
# File 'lib/head_music/instrument/pitch_variant.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_schemes ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/head_music/instrument/pitch_variant.rb', line 16 def staff_schemes @staff_schemes ||= (attributes["staff_schemes"] || {}).map do |key, list| HeadMusic::Instrument::StaffScheme.new( key: key, pitch_variant: self, list: list ) end end |