Sha256: aefacd5e8a6459e435d95dc4ea7655c9e06f633dff9ea11775ef3b7175150f68

Contents?: true

Size: 633 Bytes

Versions: 9

Compression:

Stored size: 633 Bytes

Contents

module RBMusic

  class Scale
    attr_reader :key
    attr_reader :degrees

    def initialize(key, name)
      @scale_name = name.to_sym
      raise ArgumentError unless NOTES.has_key?(key)
      raise ArgumentError unless SCALES.has_key?(@scale_name)
      @key = key
      @degrees = [:unison] + SCALES[@scale_name]
    end

    def degree_count
      @degree_count ||= @degrees.size
    end
    alias_method :size, :degree_count

    def name
      @name ||= "#{key} #{human_scale_name}"
    end

    private
    def human_scale_name
      @scale_name.to_s.split("_").map { |word| word.capitalize }.join(" ")
    end
  end

end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
rb-music-0.0.6 lib/rb-music/scale.rb
motion-music-0.0.6 lib/rb-music/scale.rb
rb-music-0.0.5 lib/rb-music/scale.rb
motion-music-0.0.5 lib/rb-music/scale.rb
rb-music-0.0.4 lib/rb-music/scale.rb
motion-music-0.0.4 lib/rb-music/scale.rb
motion-music-0.0.3 lib/rb-music/scale.rb
motion-music-0.0.2 lib/rb-music/scale.rb
rb-music-0.0.1 lib/rb-music/scale.rb