Class: Coltrane::Theory::ChordQuality
- Inherits:
-
IntervalSequence
- Object
- IntervalSequence
- Coltrane::Theory::ChordQuality
- Includes:
- Qualities
- Defined in:
- lib/coltrane/theory/chord_quality.rb
Overview
It describe the quality of a chord, like maj7 or dim.
Constant Summary
Constants included from Qualities
Instance Attribute Summary collapse
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Attributes inherited from IntervalSequence
Instance Method Summary collapse
- #get_name ⇒ Object
-
#initialize(name: nil, notes: nil, bass: nil) ⇒ ChordQuality
constructor
A new instance of ChordQuality.
- #suspension_type ⇒ Object
Methods inherited from IntervalSequence
#&, #[], #all, #find, #find_by_distance, #full_names, #has?, #interval_names, #intervals_semitones, #inversion, #inversions, #names, #next_inversion, #notes_for, #previous_inversion, #relative_intervals, #shift, #zero_it
Constructor Details
#initialize(name: nil, notes: nil, bass: nil) ⇒ ChordQuality
Returns a new instance of ChordQuality.
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/coltrane/theory/chord_quality.rb', line 92 def initialize(name: nil, notes: nil, bass: nil) if name @name = bass.nil? ? name : [name, bass].join('/') super(*intervals_from_name(name)) elsif notes super(notes: notes) @name = get_name else raise WrongKeywordsError, '[name:] || [notes:]' end end |
Instance Attribute Details
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
8 9 10 |
# File 'lib/coltrane/theory/chord_quality.rb', line 8 def name @name end |
Instance Method Details
#get_name ⇒ Object
77 78 79 80 81 82 |
# File 'lib/coltrane/theory/chord_quality.rb', line 77 def get_name find_chord(retrieve_chord_intervals.compact) || find_chord(retrieve_chord_intervals(sus2_sequence).compact) || find_chord(retrieve_chord_intervals(sus4_sequence).compact) || raise(ChordNotFoundError) end |
#suspension_type ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/coltrane/theory/chord_quality.rb', line 84 def suspension_type if has_major_second? 'sus2' else has_fourth? 'sus4' end end |