lib/head_music/instrument.rb in head_music-6.0.1 vs lib/head_music/instrument.rb in head_music-7.0.0
- old
+ new
@@ -7,12 +7,12 @@
# family_key: the key for the family of the instrument (e.g. "saxophone")
# classification_keys: an array of classification_keys
# default_clefs: the default clef or system of clefs for the instrument
# - [treble] for instruments that use the treble clef
# - [treble, bass] for instruments that use the grand staff
-# pitch_variants:
-# a hash of default and alternative fundamental pitches.
+# variants:
+# a hash of default and alternative pitch designations
# Associations:
# family: the family of the instrument (e.g. "saxophone")
# orchestra_section: the section of the orchestra (e.g. "strings")
class HeadMusic::Instrument
include HeadMusic::Named
@@ -30,11 +30,11 @@
end
attr_reader(
:name_key, :alias_name_keys,
:family_key, :orchestra_section_key,
- :pitch_variants, :classification_keys
+ :variants, :classification_keys
)
def ==(other)
to_s == other.to_s
end
@@ -73,16 +73,16 @@
return false if default_clefs.compact.uniq == [HeadMusic::Clef.get("neutral_clef")]
default_clefs.any?
end
- def default_pitch_variant
- pitch_variants.find(&:default?) || pitch_variants.first
+ def default_variant
+ variants.find(&:default?) || variants.first
end
def default_staff_scheme
- default_pitch_variant&.default_staff_scheme
+ default_variant&.default_staff_scheme
end
def default_staves
default_staff_scheme&.staves || []
end
@@ -156,12 +156,12 @@
end
def initialize_attributes(record)
@orchestra_section_key ||= record["orchestra_section_key"]
@classification_keys = [@classification_keys, record["classification_keys"]].flatten.compact.uniq
- @pitch_variants =
- (record["pitch_variants"] || {}).map do |key, attributes|
- HeadMusic::Instrument::PitchVariant.new(key, attributes)
+ @variants =
+ (record["variants"] || {}).map do |key, attributes|
+ HeadMusic::Instrument::Variant.new(key, attributes)
end
end
def inferred_name
name_key.to_s.tr("_", " ")