class Fretboard::Note

Public Class Methods

new(note) click to toggle source
# File lib/fretboard/note.rb, line 36
def initialize(note)
  @note = note
end
next_for(note, sharp_or_flat: :both) click to toggle source

Fretboard::Note.next_for('C') Fretboard::Note.next_for(['F#', 'Gb']) Fretboard::Note.next_for('F#/Gb')

# File lib/fretboard/note.rb, line 11
def self.next_for(note, sharp_or_flat: :both)
  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