Class: HeadMusic::Rudiment::Spelling::EnharmonicEquivalence
- Inherits:
-
Object
- Object
- HeadMusic::Rudiment::Spelling::EnharmonicEquivalence
- Defined in:
- lib/head_music/rudiment/spelling.rb
Overview
Enharmonic equivalence occurs when two spellings refer to the same pitch class, such as D# and Eb.
Instance Attribute Summary collapse
-
#spelling ⇒ Object
readonly
Returns the value of attribute spelling.
Class Method Summary collapse
Instance Method Summary collapse
- #enharmonic_equivalent?(other) ⇒ Boolean (also: #enharmonic?, #equivalent?)
-
#initialize(spelling) ⇒ EnharmonicEquivalence
constructor
A new instance of EnharmonicEquivalence.
Constructor Details
#initialize(spelling) ⇒ EnharmonicEquivalence
Returns a new instance of EnharmonicEquivalence.
108 109 110 |
# File 'lib/head_music/rudiment/spelling.rb', line 108 def initialize(spelling) @spelling = HeadMusic::Rudiment::Spelling.get(spelling) end |
Instance Attribute Details
#spelling ⇒ Object (readonly)
Returns the value of attribute spelling.
106 107 108 |
# File 'lib/head_music/rudiment/spelling.rb', line 106 def spelling @spelling end |
Class Method Details
.get(spelling) ⇒ Object
100 101 102 103 104 |
# File 'lib/head_music/rudiment/spelling.rb', line 100 def self.get(spelling) spelling = HeadMusic::Rudiment::Spelling.get(spelling) @enharmonic_equivalences ||= {} @enharmonic_equivalences[spelling.to_s] ||= new(spelling) end |
Instance Method Details
#enharmonic_equivalent?(other) ⇒ Boolean Also known as: enharmonic?, equivalent?
112 113 114 115 |
# File 'lib/head_music/rudiment/spelling.rb', line 112 def enharmonic_equivalent?(other) other = HeadMusic::Rudiment::Spelling.get(other) spelling != other && spelling.pitch_class_number == other.pitch_class_number end |