pedrozath/coltrane

View on GitHub
lib/coltrane/theory/key.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module Coltrane
  module Theory
    class Key < DiatonicScale
      KEY_REGEX = /([A-G][#b]?)([mM]?)/

      def initialize(notation)
        _, note, s = *notation.match(KEY_REGEX)
        super(note, major: s != 'm')
      end

      def self.[](notation)
        new(notation)
      end
    end
  end
end