Class: HeadMusic::Instruments::InstrumentFamily
- Inherits:
-
Object
- Object
- HeadMusic::Instruments::InstrumentFamily
- Includes:
- Named
- Defined in:
- lib/head_music/instruments/instrument_family.rb
Overview
An InstrumentFamily is a species of instrument that may exist in a variety of keys or other variations. For example, saxophone is an instrument family, while _alto saxophone_ and _baritone saxophone_ are specific instruments.
Constant Summary collapse
- INSTRUMENT_FAMILIES =
YAML.load_file(File.("instrument_families.yml", __dir__)).freeze
Instance Attribute Summary collapse
-
#classification_keys ⇒ Object
readonly
Returns the value of attribute classification_keys.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_key ⇒ Object
readonly
Returns the value of attribute name_key.
-
#orchestra_section_key ⇒ Object
readonly
Returns the value of attribute orchestra_section_key.
Attributes included from Named
Class Method Summary collapse
Methods included from Named
#ensure_localized_name, included, #localized_name, #localized_names
Instance Attribute Details
#classification_keys ⇒ Object (readonly)
Returns the value of attribute classification_keys.
14 15 16 |
# File 'lib/head_music/instruments/instrument_family.rb', line 14 def classification_keys @classification_keys end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/head_music/instruments/instrument_family.rb', line 15 def name @name end |
#name_key ⇒ Object (readonly)
Returns the value of attribute name_key.
14 15 16 |
# File 'lib/head_music/instruments/instrument_family.rb', line 14 def name_key @name_key end |
#orchestra_section_key ⇒ Object (readonly)
Returns the value of attribute orchestra_section_key.
14 15 16 |
# File 'lib/head_music/instruments/instrument_family.rb', line 14 def orchestra_section_key @orchestra_section_key end |
Class Method Details
.all ⇒ Object
22 23 24 25 |
# File 'lib/head_music/instruments/instrument_family.rb', line 22 def self.all @all ||= INSTRUMENT_FAMILIES.map { |key, _data| get(key) }.sort_by(&:name) end |
.get(name) ⇒ Object
17 18 19 20 |
# File 'lib/head_music/instruments/instrument_family.rb', line 17 def self.get(name) result = get_by_name(name) || get_by_name(key_for_name(name)) result || new(name) end |