Class: HeadMusic::Style::Guidelines::MinimumMelodicIntervals

Inherits:
MinimumThreshold 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).

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from HeadMusic::Style::Annotation

Instance Method Details

#actual_countObject (private)



30
31
32
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 30

def actual_count
  moving_intervals.length
end

#marksObject



8
9
10
11
12
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 8

def marks
  return no_motion_mark if moving_intervals.empty?

  deficiency_mark
end

#messageObject



14
15
16
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 14

def message
  "Write at least #{minimum.humanize} melodic intervals."
end

#moving_intervalsObject (private)



20
21
22
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 20

def moving_intervals
  melodic_intervals.select(&:moving?)
end

#no_motion_markObject (private)



24
25
26
27
28
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 24

def no_motion_mark
  return no_placements_mark if placements.empty?

  HeadMusic::Style::Mark.for_all(placements, fitness: 0)
end