Sha256: 36ea26ade2232a218ef173518ec388e377a12bb6daa2e1f83c88e6ed3fd3489e

Contents?: true

Size: 755 Bytes

Versions: 18

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

# Module for style guidelines.
module HeadMusic::Style::Guidelines; end

# A counterpoint guideline
class HeadMusic::Style::Guidelines::StepDownToFinalNote < HeadMusic::Style::Annotation
  MESSAGE = 'Step down to the final note.'

  def marks
    return if last_melodic_interval.nil?

    fitness = 1
    fitness *= HeadMusic::PENALTY_FACTOR unless step?
    fitness *= HeadMusic::PENALTY_FACTOR unless descending?
    HeadMusic::Style::Mark.for_all(notes[-2..-1], fitness: fitness) if fitness < 1
  end

  private

  def descending?
    last_melodic_interval&.descending?
  end

  def step?
    last_melodic_interval&.step?
  end

  def last_melodic_interval
    @last_melodic_interval ||= melodic_intervals.last
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
head_music-0.27.0 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.26.3 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.26.2 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.26.1 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.26.0 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.25.0 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.24.5 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.24.4 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.24.3 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.24.2 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.24.1 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.24.0 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.23.4 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.23.3 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.23.2 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.23.1 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.23.0 lib/head_music/style/guidelines/step_down_to_final_note.rb
head_music-0.22.0 lib/head_music/style/guidelines/step_down_to_final_note.rb