class HeadMusic::Quality
A quality is a categorization of an interval.
Constants
- MAJOR_INTERVAL_MODIFICATION
- NAMES
- PERFECT_INTERVAL_MODIFICATION
- SHORTHAND
Attributes
name[R]
Public Class Methods
from(starting_quality, delta)
click to toggle source
# File lib/head_music/quality.rb, line 38 def self.from(starting_quality, delta) if starting_quality == :perfect PERFECT_INTERVAL_MODIFICATION[delta].to_s.gsub(/_+/, ' ') elsif starting_quality == :major MAJOR_INTERVAL_MODIFICATION[delta].to_s.gsub(/_+/, ' ') end end
get(identifier)
click to toggle source
# File lib/head_music/quality.rb, line 32 def self.get(identifier) @qualities ||= {} identifier = identifier.to_s.to_sym @qualities[identifier] ||= new(identifier) if NAMES.include?(identifier) end
Private Class Methods
new(name)
click to toggle source
# File lib/head_music/quality.rb, line 50 def initialize(name) @name = name end
Public Instance Methods
==(other)
click to toggle source
# File lib/head_music/quality.rb, line 54 def ==(other) to_s == other.to_s end
article()
click to toggle source
# File lib/head_music/quality.rb, line 62 def article %w[a e i o u h].include?(name.to_s.first) ? 'an' : 'a' end
shorthand()
click to toggle source
# File lib/head_music/quality.rb, line 58 def shorthand SHORTHAND[name] end