Sha256: a2110a30ee8e4265f3fb91876761896ad65fc831d3857c508b3849c8ad26cc19

Contents?: true

Size: 410 Bytes

Versions: 2

Compression:

Stored size: 410 Bytes

Contents

class HeadMusic::Consonance
  LEVELS = %w[perfect imperfect dissonant]

  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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
head_music-0.10.0 lib/head_music/consonance.rb
head_music-0.5.2 lib/head_music/consonance.rb