Class: HeadMusic::Style::Guidelines::MinimumNotes
- Inherits:
-
Annotation
- Object
- Annotation
- HeadMusic::Style::Guidelines::MinimumNotes
show all
- Defined in:
- lib/head_music/style/guidelines/minimum_notes.rb
Overview
Flags a melody with fewer than the required number of notes.
Configure the threshold with the factory, e.g. MinimumNotes.with(8).
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.with(minimum) ⇒ Object
7
8
9
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 7
def self.with(minimum)
super(minimum: minimum)
end
|
Instance Method Details
#deficiency_mark ⇒ Object
33
34
35
36
37
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 33
def deficiency_mark
return unless notes.length < minimum
HeadMusic::Style::Mark.for_all(placements, fitness: notes.length.to_f / minimum)
end
|
#marks ⇒ Object
11
12
13
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 11
def marks
placements.empty? ? no_placements_mark : deficiency_mark
end
|
#message ⇒ Object
15
16
17
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 15
def message
"Write at least #{minimum.humanize} notes."
end
|
#minimum ⇒ Object
21
22
23
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 21
def minimum
options.fetch(:minimum)
end
|
#no_placements_mark ⇒ Object