Sha256: 567f3a7a9a044468e7042a5cf5ec93969b58534a6695e4c95222b92ca95fc382
Contents?: true
Size: 1000 Bytes
Versions: 1
Compression:
Stored size: 1000 Bytes
Contents
class HeadMusic::Quality SHORTHAND = { perfect: 'P', major: 'M', minor: 'm', diminished: 'd', augmented: 'A', doubly_diminished: 'dd', doubly_augmented: 'AA', } NAMES = SHORTHAND.keys PERFECT_INTERVAL_MODIFICATION = { -2 => :doubly_diminished, -1 => :diminished, 0 => :perfect, 1 => :augmented, 2 => :doubly_augmented } MAJOR_INTERVAL_MODIFICATION = { -2 => :diminished, -1 => :minor, 0 => :major, 1 => :augmented, 2 => :doubly_augmented } def self.get(identifier) @qualities ||= {} identifier = identifier.to_s.to_sym @qualities[identifier] ||= new(identifier) if NAMES.include?(identifier) end attr_reader :name delegate :to_s, to: :name def initialize(name) @name = name end def ==(other) self.to_s == other.to_s end def shorthand SHORTHAND[name] end def article %w[a e i o u h].include?(name.to_s.first) ? 'an' : 'a' end private_class_method :new end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
head_music-0.5.0 | lib/head_music/quality.rb |