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