Class: HeadMusic::Notation::LilyPond::FlowBuilder::Cursor

Inherits:
Object
  • Object
show all
Defined in:
lib/head_music/notation/lily_pond/flow_builder.rb

Overview

One voice's place in the replay: the events it has left, and the voice they are being placed on.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream, voice) ⇒ Cursor

Returns a new instance of Cursor.



16
17
18
19
# File 'lib/head_music/notation/lily_pond/flow_builder.rb', line 16

def initialize(stream, voice)
  @events = stream.events.dup
  @voice = voice
end

Instance Attribute Details

#voice ⇒ Object (readonly)

Returns the value of attribute voice.



14
15
16
# File 'lib/head_music/notation/lily_pond/flow_builder.rb', line 14

def voice
  @voice
end

Instance Method Details

#advance ⇒ Object



29
30
31
# File 'lib/head_music/notation/lily_pond/flow_builder.rb', line 29

def advance
  @events.shift
end

#done? ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/head_music/notation/lily_pond/flow_builder.rb', line 25

def done?
  @events.empty?
end

#event ⇒ Object



21
22
23
# File 'lib/head_music/notation/lily_pond/flow_builder.rb', line 21

def event
  @events.first
end

#sort_key ⇒ Object

Key and meter changes are answered before the notes of the same position, so a bar is placed under the meter that governs it.



35
36
37
# File 'lib/head_music/notation/lily_pond/flow_builder.rb', line 35

def sort_key
  [voice.next_position, event.music? ? 1 : 0]
end