Class: Fretboard::Note
- Inherits:
-
Object
- Object
- Fretboard::Note
- Defined in:
- lib/fretboard/note.rb
Class Method Summary collapse
-
.next_for(note, sharp_or_flat: :both) ⇒ Object
Fretboard::Note.next_for(‘C’) Fretboard::Note.next_for([‘F#’, ‘Gb’]) Fretboard::Note.next_for(‘F#/Gb’).
Instance Method Summary collapse
-
#initialize(note) ⇒ Note
constructor
A new instance of Note.
Constructor Details
#initialize(note) ⇒ Note
Returns a new instance of Note.
34 35 36 |
# File 'lib/fretboard/note.rb', line 34 def initialize(note) @note = note end |
Class Method Details
.next_for(note, sharp_or_flat: :both) ⇒ Object
Fretboard::Note.next_for(‘C’) Fretboard::Note.next_for([‘F#’, ‘Gb’]) Fretboard::Note.next_for(‘F#/Gb’)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fretboard/note.rb', line 11 def self.next_for(note, sharp_or_flat: :both) # rubocop:disable Metrics/MethodLength all_notes = Fretboard::Notes.all(sharp_or_flat) if note.is_a?(Array) note = case sharp_or_flat when :both note.join("/") when :sharp note.first else note.last end end current_index = all_notes.find_index(note) next_index = current_index + 1 next_note = all_notes[next_index] next_note = all_notes.first if next_note.blank? next_note end |