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).

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Class Method Details

.template_values(config) ⇒ Object

The count comes from the configuration or the class default – never from config alone, which is empty for the unconfigured case.



16
17
18
19
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 16

def self.template_values(config)
  count = config.fetch(:minimum)
  {count: count, number: HeadMusic::Style::Template.number_word(count)}
end

Instance Method Details

#actual_countObject (private)



33
34
35
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 33

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

#moving_intervalsObject (private)



23
24
25
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 23

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

#no_motion_markObject (private)



27
28
29
30
31
# File 'lib/head_music/style/guidelines/minimum_melodic_intervals.rb', line 27

def no_motion_mark
  return no_placements_mark if placements.empty?

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