Class: HeadMusic::InstrumentFamily

Inherits:
Object
  • Object
show all
Includes:
Named
Defined in:
lib/head_music/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.expand_path("data/instrument_families.yml", __dir__)).freeze

Instance Attribute Summary collapse

Attributes included from Named

#alias_name_keys

Class Method Summary collapse

Methods included from Named

#ensure_localized_name, included, #localized_name, #localized_names

Instance Attribute Details

#classification_keysObject (readonly)

Returns the value of attribute classification_keys.



11
12
13
# File 'lib/head_music/instrument_family.rb', line 11

def classification_keys
  @classification_keys
end

#default_staffsObject (readonly)

Returns the value of attribute default_staffs.



11
12
13
# File 'lib/head_music/instrument_family.rb', line 11

def default_staffs
  @default_staffs
end

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/head_music/instrument_family.rb', line 12

def name
  @name
end

#name_keyObject (readonly)

Returns the value of attribute name_key.



11
12
13
# File 'lib/head_music/instrument_family.rb', line 11

def name_key
  @name_key
end

#orchestra_section_keyObject (readonly)

Returns the value of attribute orchestra_section_key.



11
12
13
# File 'lib/head_music/instrument_family.rb', line 11

def orchestra_section_key
  @orchestra_section_key
end

Class Method Details

.allObject



19
20
21
22
# File 'lib/head_music/instrument_family.rb', line 19

def self.all
  @all ||=
    INSTRUMENT_FAMILIES.map { |key, _data| get(key) }.sort_by(&:name)
end

.get(name) ⇒ Object



14
15
16
17
# File 'lib/head_music/instrument_family.rb', line 14

def self.get(name)
  result = get_by_name(name) || get_by_name(key_for_name(name))
  result || new(name)
end