lib/head_music/instrument.rb in head_music-0.24.4 vs lib/head_music/instrument.rb in head_music-0.24.5

- old
+ new

@@ -21,10 +21,16 @@ def ==(other) to_s == other.to_s end + def translation(locale = :en) + return name unless name_key + + I18n.translate(name_key, scope: [:instruments], locale: locale) + end + private_class_method :new private def initialize(name) @@ -53,9 +59,10 @@ 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 end + nil end def initialize_data_from_record(record) @name_key = record['name_key'].to_sym @family = record['family']