Sha256: 95176210623e8feaf360a0b7f643cc00dfcce8cc43d506f160797780461f7409

Contents?: true

Size: 461 Bytes

Versions: 19

Compression:

Stored size: 461 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

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

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
head_music-0.17.0 lib/head_music/consonance.rb
head_music-0.16.2 lib/head_music/consonance.rb
head_music-0.16.0 lib/head_music/consonance.rb
head_music-0.14.8 lib/head_music/consonance.rb
head_music-0.14.7 lib/head_music/consonance.rb
head_music-0.14.5 lib/head_music/consonance.rb
head_music-0.14.4 lib/head_music/consonance.rb
head_music-0.14.2 lib/head_music/consonance.rb
head_music-0.14.1 lib/head_music/consonance.rb
head_music-0.13.2 lib/head_music/consonance.rb
head_music-0.11.9 lib/head_music/consonance.rb
head_music-0.11.8 lib/head_music/consonance.rb
head_music-0.11.7 lib/head_music/consonance.rb
head_music-0.11.6 lib/head_music/consonance.rb
head_music-0.11.5 lib/head_music/consonance.rb
head_music-0.11.4 lib/head_music/consonance.rb
head_music-0.11.3 lib/head_music/consonance.rb
head_music-0.11.2 lib/head_music/consonance.rb
head_music-0.11.1 lib/head_music/consonance.rb