lib/head_music/octave.rb in head_music-0.20.0 vs lib/head_music/octave.rb in head_music-0.22.0
- old
+ new
@@ -11,15 +11,17 @@
end
def self.from_number(identifier)
return nil unless identifier.to_s == identifier.to_i.to_s
return nil unless (-2..12).cover?(identifier.to_i)
+
@octaves ||= {}
@octaves[identifier.to_i] ||= new(identifier.to_i)
end
def self.from_name(string)
return unless string.to_s.match?(HeadMusic::Spelling::MATCHER)
+
_letter, _sign, octave_string = string.to_s.match(HeadMusic::Spelling::MATCHER).captures
@octaves ||= {}
@octaves[octave_string.to_i] ||= new(octave_string.to_i) if octave_string
end