class Musicality::NoteArray
Attributes
duration[R]
notes[R]
Public Class Methods
new(notes)
click to toggle source
# File lib/musicality/composition/sequencing/note_array.rb, line 7 def initialize notes raise ArgumentError if notes.empty? @notes = notes.clone.freeze @notes_idx = 0 @notes_count = notes.size @duration = @notes.inject(0) {|sum, note| sum + note.duration} end
Public Instance Methods
next_note()
click to toggle source
# File lib/musicality/composition/sequencing/note_array.rb, line 17 def next_note note = @notes[@notes_idx] @notes_idx += 1 if @notes_idx >= @notes_count @notes_idx = 0 end return note end
reset()
click to toggle source
# File lib/musicality/composition/sequencing/note_array.rb, line 28 def reset @notes_idx = 0 end