Class: HeadMusic::Style::Guidelines::NoteCountPerBar
- Inherits:
-
Annotation
- Object
- Annotation
- HeadMusic::Style::Guidelines::NoteCountPerBar
show all
- Defined in:
- lib/head_music/style/guidelines/note_count_per_bar.rb
Overview
Base class for guidelines that check note counts in middle bars (not first or last).
Instance Method Summary
collapse
Instance Method Details
#mark_bar(bar_number) ⇒ Object
25
26
27
28
29
30
31
32
33
|
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 25
def mark_bar(bar_number)
bar_placements = notes_in_bar(bar_number)
if bar_placements.any?
HeadMusic::Style::Mark.for_all(bar_placements)
else
cf_note = cantus_firmus.notes.detect { |note| note.position.bar_number == bar_number }
HeadMusic::Style::Mark.for(cf_note) if cf_note
end
end
|
#marks ⇒ Object
6
7
8
9
10
|
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 6
def marks
return [] unless cantus_firmus&.notes&.any?
middle_bars.filter_map { |bar_number| check_middle_bar(bar_number) }
end
|
#middle_bars ⇒ Object
14
15
16
17
18
19
|
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 14
def middle_bars
cf_notes = cantus_firmus.notes
return [] if cf_notes.length <= 2
cf_notes[1..-2].map { |note| note.position.bar_number }
end
|
#notes_in_bar(bar_number) ⇒ Object
21
22
23
|
# File 'lib/head_music/style/guidelines/note_count_per_bar.rb', line 21
def notes_in_bar(bar_number)
notes.select { |note| note.position.bar_number == bar_number }
end
|