Class: MusicUtils::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/music-utils/note/note.rb

Overview

Represents a music note

Class Method Summary collapse

Class Method Details

.parse(note) ⇒ Object

Parse notes to obtaining the raw note and its alterations separately



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/music-utils/note/note.rb', line 7

def self.parse(note)
  n = 0
  
  # SOL is the only note of length = 3
  n += 1 if note[0..2].to_sym == MusicUtils::SOL
  
  note_aux = note[0..1 + n].to_sym
  note_alt = note[2 + n..3 + n]

  [note_aux, note_alt]
end