Class: Fretboard::Note
- Inherits:
-
Object
- Object
- Fretboard::Note
- Defined in:
- lib/fretboard/note.rb
Class Method Summary collapse
- .formated(note) ⇒ Object
-
.next_for(note, sharp_or_flat: :sharp, formated: false) ⇒ Object
Fretboard::Note.next_for(‘C’).
Instance Method Summary collapse
- #formated ⇒ Object
-
#initialize(note) ⇒ Note
constructor
A new instance of Note.
Constructor Details
#initialize(note) ⇒ Note
Returns a new instance of Note.
26 27 28 |
# File 'lib/fretboard/note.rb', line 26 def initialize(note) @note = note end |
Class Method Details
.formated(note) ⇒ Object
22 23 24 |
# File 'lib/fretboard/note.rb', line 22 def self.formated(note) new(note).formated end |
.next_for(note, sharp_or_flat: :sharp, formated: false) ⇒ Object
Fretboard::Note.next_for(‘C’)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fretboard/note.rb', line 7 def self.next_for(note, sharp_or_flat: :sharp, formated: false) all_notes = Fretboard::Notes.all( sharp_or_flat, formated: formated ) 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 |
Instance Method Details
#formated ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fretboard/note.rb', line 30 def formated result = @note result = result.gsub('sharp', '#') if result.include?('sharp') if result.include?('flat') result = result.gsub('flat', 'b') # ♭ end result.gsub(' ', '') end |