Skip to content

Commit

Permalink
feat(enharmonic): implement items getter
Browse files Browse the repository at this point in the history
  • Loading branch information
albertms10 committed Apr 7, 2023
1 parent 1ada113 commit 6cf9ecd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
3 changes: 1 addition & 2 deletions lib/src/classes/enharmonic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ abstract class Enharmonic<T extends MusicItem>
);

/// Returns the items sharing the same [semitones].
// TODO(albertms10): implement method.
Set<T> get items => {};
Set<T> get items;

/// Returns a transposed [Enharmonic] by [semitones] from this [Enharmonic].
@override
Expand Down
4 changes: 2 additions & 2 deletions lib/src/classes/enharmonic_interval.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ part of '../../music_notes.dart';
class EnharmonicInterval extends Enharmonic<Interval> {
const EnharmonicInterval(super.semitones);

/// Returns the [EnharmonicInterval] from [semitones].
static Set<Interval> _fromSemitones(int semitones) {
@override
Set<Interval> get items {
final interval = IntervalsValues.fromSemitones(semitones);

if (interval != null) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/classes/enharmonic_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class EnharmonicNote extends Enharmonic<Note> {
static const aSharp = EnharmonicNote(11);
static const b = EnharmonicNote(12);

/// Returns the [EnharmonicNote] from [semitones].
static Set<Note> _fromSemitones(int semitones) {
@override
Set<Note> get items {
final note = NotesValues.fromValue(semitones);

if (note != null) {
Expand Down
14 changes: 0 additions & 14 deletions test/enharmonic_interval_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,4 @@ void main() {
equals(const Interval(Intervals.fifth, Qualities.diminished)),
);
});

test('Items are correct', () {
expect(const EnharmonicInterval(6).items, {
const Interval(Intervals.fourth, Qualities.augmented),
const Interval(Intervals.fifth, Qualities.diminished),
});
expect(const EnharmonicInterval(4).items, {
const Interval(Intervals.third, Qualities.major),
const Interval(Intervals.fourth, Qualities.diminished),
});
expect(const EnharmonicInterval(2).items, {
const Interval(Intervals.second, Qualities.major),
});
});
}

0 comments on commit 6cf9ecd

Please sign in to comment.