lib/head_music/clef.rb in head_music-0.5.4 vs lib/head_music/clef.rb in head_music-0.6.0
- old
+ new
@@ -18,18 +18,20 @@
]
def self.get(name)
name = name.to_s
@clefs ||= {}
- @clefs[name.to_s.to_sym] = new(name)
+ key = HeadMusic::Utilities::HashKey.for(name)
+ @clefs[key] ||= new(name)
end
attr_reader :name, :pitch, :line
+ delegate :to_s, to: :name
def initialize(name)
@name = name.to_s
- clef_data = CLEFS.detect { |clef| clef[:names].include?(name) }
+ clef_data = CLEFS.detect { |clef| clef[:names].map(&:downcase).include?(name.downcase) }
@pitch = HeadMusic::Pitch.get(clef_data[:pitch])
@line = clef_data[:line]
end
def clef_type
@@ -48,7 +50,11 @@
@space_pitches ||= {}
@space_pitches[space_number] ||= begin
steps = (space_number - line) * 2 + 1
pitch.natural_steps(steps)
end
+ end
+
+ def ==(other)
+ to_s == other.to_s
end
end