Skip to content

Commit

Permalink
refactor!(quality): ♻️ rename abbreviationsymbol getter (#356)
Browse files Browse the repository at this point in the history
* refactor!(quality): ♻️ rename `abbreviation` → `symbol` getter

* docs(quality): 📖 use `Quality` identifier for commented `_augmentedSymbol`
  • Loading branch information
albertms10 committed Jan 13, 2024
1 parent aa29e75 commit 55bc364
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/src/interval/interval.dart
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,11 @@ final class Interval implements Comparable<Interval> {

@override
String toString() {
final naming = '${quality.abbreviation}${size.abs()}';
final naming = '${quality.symbol}${size.abs()}';
final descendingAbbreviation = isDescending ? 'desc ' : '';
if (isCompound) {
return '$descendingAbbreviation$naming '
'(${quality.abbreviation}${simplified.size.abs()})';
'(${quality.symbol}${simplified.size.abs()})';
}

return '$descendingAbbreviation$naming';
Expand Down
14 changes: 7 additions & 7 deletions lib/src/interval/quality.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ sealed class Quality implements Comparable<Quality> {
static const _diminishedSymbol = 'd';
static const _augmentedSymbol = 'A';

/// The textual abbreviation of this [Quality].
String get abbreviation;
/// The symbol of this [Quality].
String get symbol;

/// Returns the inverted version of this [Quality].
Quality get inverted;

@override
String toString() => '$abbreviation (${semitones.toDeltaString()})';
String toString() => '$symbol (${semitones.toDeltaString()})';

@override
bool operator ==(Object other) =>
Expand Down Expand Up @@ -100,12 +100,12 @@ class PerfectQuality extends Quality {
return switch (source[0]) {
Quality._diminishedSymbol => PerfectQuality(-source.length),
_perfectSymbol => PerfectQuality.perfect,
_ /* _augmentedSymbol */ => PerfectQuality(source.length),
_ /* Quality._augmentedSymbol */ => PerfectQuality(source.length),
};
}

@override
String get abbreviation => switch (semitones) {
String get symbol => switch (semitones) {
< 0 => Quality._diminishedSymbol * semitones.abs(),
0 => _perfectSymbol,
_ => Quality._augmentedSymbol * semitones,
Expand Down Expand Up @@ -189,12 +189,12 @@ class ImperfectQuality extends Quality {
Quality._diminishedSymbol => ImperfectQuality(-source.length),
_minorSymbol => ImperfectQuality.minor,
_majorSymbol => ImperfectQuality.major,
_ /* _augmentedSymbol */ => ImperfectQuality(source.length + 1),
_ /* Quality._augmentedSymbol */ => ImperfectQuality(source.length + 1),
};
}

@override
String get abbreviation => switch (semitones) {
String get symbol => switch (semitones) {
< 0 => Quality._diminishedSymbol * semitones.abs(),
0 => _minorSymbol,
1 => _majorSymbol,
Expand Down

0 comments on commit 55bc364

Please sign in to comment.