Class: HeadMusic::Pitch::OctaveEquivalence
- Inherits:
-
Object
- Object
- HeadMusic::Pitch::OctaveEquivalence
- Defined in:
- lib/head_music/pitch/octave_equivalence.rb
Overview
Octave equivalence is the functional equivalence of pitches with the same spelling separated by one or more octaves.
Instance Attribute Summary collapse
-
#pitch ⇒ Object
readonly
Returns the value of attribute pitch.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(pitch) ⇒ OctaveEquivalence
constructor
A new instance of OctaveEquivalence.
- #octave_equivalent?(other) ⇒ Boolean (also: #equivalent?)
Constructor Details
#initialize(pitch) ⇒ OctaveEquivalence
Returns a new instance of OctaveEquivalence.
12 13 14 |
# File 'lib/head_music/pitch/octave_equivalence.rb', line 12 def initialize(pitch) @pitch = pitch end |
Instance Attribute Details
#pitch ⇒ Object (readonly)
Returns the value of attribute pitch.
10 11 12 |
# File 'lib/head_music/pitch/octave_equivalence.rb', line 10 def pitch @pitch end |
Class Method Details
.get(pitch) ⇒ Object
5 6 7 8 |
# File 'lib/head_music/pitch/octave_equivalence.rb', line 5 def self.get(pitch) @octave_equivalences ||= {} @octave_equivalences[pitch.to_s] ||= new(pitch) end |