Class: HeadMusic::Style::Guidelines::MinimumMelodicIntervals
- Inherits:
-
Annotation
- Object
- Annotation
- HeadMusic::Style::Guidelines::MinimumMelodicIntervals
show all
- Defined in:
- lib/head_music/style/guidelines/minimum_melodic_intervals.rb
Overview
Flags a melody with fewer than the required number of moving melodic intervals.
Repeated-note pairs don’t count as motion, so an all-repeated-note line gates to 0.
Configure the threshold with the factory, e.g. MinimumMelodicIntervals.with(2).
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.default_gate? ⇒ Boolean
12
13
14
|
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 12
def self.default_gate?
true
end
|
.with(minimum, **options) ⇒ Object
8
9
10
|
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 8
def self.with(minimum, **options)
super(minimum: minimum, **options)
end
|
Instance Method Details
#deficiency_mark ⇒ Object
50
51
52
53
54
|
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 50
def deficiency_mark
return unless moving_intervals.length < minimum
HeadMusic::Style::Mark.for_all(placements, fitness: moving_intervals.length.to_f / minimum)
end
|
#marks ⇒ Object
16
17
18
19
20
|
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 16
def marks
return no_motion_mark if moving_intervals.empty?
deficiency_mark
end
|
#message ⇒ Object
22
23
24
|
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 22
def message
"Write at least #{minimum.humanize} melodic intervals."
end
|
#minimum ⇒ Object
28
29
30
|
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 28
def minimum
options.fetch(:minimum)
end
|
#moving_intervals ⇒ Object
32
33
34
|
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 32
def moving_intervals
melodic_intervals.select(&:moving?)
end
|
#no_motion_mark ⇒ Object
36
37
38
39
40
|
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 36
def no_motion_mark
return no_placements_mark if placements.empty?
HeadMusic::Style::Mark.for_all(placements, fitness: 0)
end
|
#no_placements_mark ⇒ Object