Class: HeadMusic::Instrument
- Inherits:
-
Object
- Object
- HeadMusic::Instrument
- Includes:
- Named
- Defined in:
- lib/head_music/instrument.rb
Overview
An instrument can be assigned to a staff.
Constant Summary collapse
- INSTRUMENTS =
YAML.load_file(File.("data/instruments.yml", __dir__)).freeze
Instance Attribute Summary collapse
-
#classifications ⇒ Object
readonly
Returns the value of attribute classifications.
-
#family ⇒ Object
readonly
Returns the value of attribute family.
-
#name_key ⇒ Object
readonly
Returns the value of attribute name_key.
-
#standard_staves ⇒ Object
readonly
Returns the value of attribute standard_staves.
Attributes included from Named
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Named
#ensure_localized_name, included, #localized_name, #localized_names, #name, #name=
Instance Attribute Details
#classifications ⇒ Object (readonly)
Returns the value of attribute classifications.
20 21 22 |
# File 'lib/head_music/instrument.rb', line 20 def classifications @classifications end |
#family ⇒ Object (readonly)
Returns the value of attribute family.
20 21 22 |
# File 'lib/head_music/instrument.rb', line 20 def family @family end |
#name_key ⇒ Object (readonly)
Returns the value of attribute name_key.
20 21 22 |
# File 'lib/head_music/instrument.rb', line 20 def name_key @name_key end |
#standard_staves ⇒ Object (readonly)
Returns the value of attribute standard_staves.
20 21 22 |
# File 'lib/head_music/instrument.rb', line 20 def standard_staves @standard_staves end |
Class Method Details
.all ⇒ Object
16 17 18 |
# File 'lib/head_music/instrument.rb', line 16 def self.all INSTRUMENTS.map { |key, _data| get(key) }.sort_by(&:name) end |
.get(name) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/head_music/instrument.rb', line 9 def self.get(name) return get_by_name(name) if get_by_name(name) return get_by_name(key_for_name(name)) if key_for_name(name) new(name) end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 |
# File 'lib/head_music/instrument.rb', line 22 def ==(other) to_s == other.to_s end |
#translation(locale = :en) ⇒ Object
26 27 28 29 30 |
# File 'lib/head_music/instrument.rb', line 26 def translation(locale = :en) return name unless name_key I18n.translate(name_key, scope: [:instruments], locale: locale) end |