lib/head_music/instrument.rb in head_music-0.27.0 vs lib/head_music/instrument.rb in head_music-0.28.0
- old
+ new
@@ -2,11 +2,11 @@
# An instrument can be assigned to a staff.
class HeadMusic::Instrument
include HeadMusic::Named
- INSTRUMENTS = YAML.load_file(File.expand_path('data/instruments.yml', __dir__)).freeze
+ INSTRUMENTS = YAML.load_file(File.expand_path("data/instruments.yml", __dir__)).freeze
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)
@@ -57,22 +57,22 @@
nil
end
def record_for_key(key)
INSTRUMENTS.each do |name_key, data|
- return data.merge!('name_key' => name_key) if name_key.to_s == key.to_s
+ return data.merge!("name_key" => name_key) if name_key.to_s == key.to_s
end
nil
end
def initialize_data_from_record(record)
- @name_key = record['name_key'].to_sym
- @family = record['family']
- @standard_staves = record['standard_staves'] || []
- @classifications = record['classifications'] || []
- self.name = I18n.translate(name_key, scope: 'instruments', locale: 'en', default: inferred_name)
+ @name_key = record["name_key"].to_sym
+ @family = record["family"]
+ @standard_staves = record["standard_staves"] || []
+ @classifications = record["classifications"] || []
+ self.name = I18n.translate(name_key, scope: "instruments", locale: "en", default: inferred_name)
end
def inferred_name
- name_key.to_s.gsub(/_/, ' ')
+ name_key.to_s.tr("_", " ")
end
end