Sha256: ca693034fb9a9015721b40f4394ef49ecafaf6f6bd4e403f142c4925dfd0d08b

Contents?: true

Size: 597 Bytes

Versions: 27

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

# Consonance describes a category or degree of harmonic pleasantness: perfect, imperfect, or dissonant
class HeadMusic::Consonance
  LEVELS = %w[perfect imperfect dissonant].freeze

  def self.get(name)
    @consonances ||= {}
    @consonances[name.to_sym] ||= new(name) if LEVELS.include?(name.to_s)
  end

  attr_reader :name

  delegate :to_s, to: :name

  def initialize(name)
    @name = name.to_s.to_sym
  end

  def ==(other)
    to_s == other.to_s
  end

  LEVELS.each do |method_name|
    define_method(:"#{method_name}?") { to_s == method_name }
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
head_music-4.0.1 lib/head_music/consonance.rb
head_music-4.0.0 lib/head_music/consonance.rb
head_music-3.0.1 lib/head_music/consonance.rb
head_music-3.0.0 lib/head_music/consonance.rb
head_music-2.0.1 lib/head_music/consonance.rb
head_music-2.0.0 lib/head_music/consonance.rb
head_music-1.0.0 lib/head_music/consonance.rb
head_music-0.29.0 lib/head_music/consonance.rb
head_music-0.28.0 lib/head_music/consonance.rb
head_music-0.27.0 lib/head_music/consonance.rb
head_music-0.26.3 lib/head_music/consonance.rb
head_music-0.26.2 lib/head_music/consonance.rb
head_music-0.26.1 lib/head_music/consonance.rb
head_music-0.26.0 lib/head_music/consonance.rb
head_music-0.25.0 lib/head_music/consonance.rb
head_music-0.24.5 lib/head_music/consonance.rb
head_music-0.24.4 lib/head_music/consonance.rb
head_music-0.24.3 lib/head_music/consonance.rb
head_music-0.24.2 lib/head_music/consonance.rb
head_music-0.24.1 lib/head_music/consonance.rb