lib/head_music/clef.rb in head_music-0.11.9 vs lib/head_music/clef.rb in head_music-0.13.2
- old
+ new
@@ -1,6 +1,8 @@
class HeadMusic::Clef
+ include HeadMusic::NamedRudiment
+
CLEFS = [
{ pitch: 'G4', line: 2, names: ['treble', 'G-clef'], modern: true },
{ pitch: 'G4', line: 1, names: ['French', 'French violin'] },
{ pitch: 'G3', line: 2, names: ['tenor'], modern: true },
@@ -16,17 +18,13 @@
{ pitch: nil, line: 3, names: ['neutral', 'percussion'] }
]
def self.get(name)
- name = name.to_s
- @clefs ||= {}
- key = HeadMusic::Utilities::HashKey.for(name)
- @clefs[key] ||= new(name)
+ get_by_name(name)
end
- attr_reader :name, :pitch, :line
- delegate :to_s, to: :name
+ attr_reader :pitch, :line
def initialize(name)
@name = name.to_s
clef_data = CLEFS.detect { |clef| clef[:names].map(&:downcase).include?(name.downcase) }
@pitch = HeadMusic::Pitch.get(clef_data[:pitch])