Class: HeadMusic::Instruments::Variant
- Inherits:
-
Object
- Object
- HeadMusic::Instruments::Variant
- Defined in:
- lib/head_music/instruments/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
- #==(other) ⇒ Object
- #default? ⇒ Boolean
- #default_staff_scheme ⇒ Object
-
#initialize(key, attributes = {}) ⇒ Variant
constructor
A new instance of Variant.
- #pitch_designation ⇒ Object
- #staff_schemes ⇒ Object
Constructor Details
#initialize(key, attributes = {}) ⇒ Variant
Returns a new instance of Variant.
7 8 9 10 |
# File 'lib/head_music/instruments/variant.rb', line 7 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.
5 6 7 |
# File 'lib/head_music/instruments/variant.rb', line 5 def attributes @attributes end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/head_music/instruments/variant.rb', line 5 def key @key end |
Instance Method Details
#==(other) ⇒ Object
39 40 41 42 43 |
# File 'lib/head_music/instruments/variant.rb', line 39 def ==(other) return false unless other.is_a?(self.class) key == other.key && attributes == other.attributes end |
#default? ⇒ Boolean
30 31 32 |
# File 'lib/head_music/instruments/variant.rb', line 30 def default? key.to_s == "default" end |
#default_staff_scheme ⇒ Object
34 35 36 37 |
# File 'lib/head_music/instruments/variant.rb', line 34 def default_staff_scheme @default_staff_scheme ||= staff_schemes.find(&:default?) || staff_schemes.first end |
#pitch_designation ⇒ Object
12 13 14 15 16 17 |
# File 'lib/head_music/instruments/variant.rb', line 12 def pitch_designation return if attributes["pitch_designation"].to_s == "" @pitch_designation ||= HeadMusic::Rudiment::Spelling.get(attributes["pitch_designation"]) end |
#staff_schemes ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/head_music/instruments/variant.rb', line 19 def staff_schemes @staff_schemes ||= (attributes["staff_schemes"] || {}).map do |key, list| HeadMusic::Instruments::StaffScheme.new( key: key, variant: self, list: list ) end end |