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
.default_gate? ⇒ Boolean
11
12
13
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 11
def self.default_gate?
true
end
|
.with(minimum, **options) ⇒ Object
7
8
9
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 7
def self.with(minimum, **options)
super(minimum: minimum, **options)
end
|
Instance Method Details
#deficiency_mark ⇒ Object
37
38
39
40
41
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 37
def deficiency_mark
return unless notes.length < minimum
HeadMusic::Style::Mark.for_all(placements, fitness: notes.length.to_f / minimum)
end
|
#marks ⇒ Object
15
16
17
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 15
def marks
placements.empty? ? no_placements_mark : deficiency_mark
end
|
#message ⇒ Object
19
20
21
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 19
def message
"Write at least #{minimum.humanize} notes."
end
|
#minimum ⇒ Object
25
26
27
|
# File 'lib/head_music/style/guidelines/minimum_notes.rb', line 25
def minimum
options.fetch(:minimum)
end
|
#no_placements_mark ⇒ Object