Sha256: 5ee65d8f5569328aca99d058ab3023ee93a5e216bb18d4142ef8ca2251334a95

Contents?: true

Size: 673 Bytes

Versions: 9

Compression:

Stored size: 673 Bytes

Contents

# frozen_string_literal: true

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

# A counterpoint guideline
class HeadMusic::Style::Guidelines::NoUnisonsInMiddle < HeadMusic::Style::Annotation
  MESSAGE = "Unisons may only be used in the first and last note."

  def marks
    unison_pairs.map do |notes|
      HeadMusic::Style::Mark.for_all(notes)
    end.flatten
  end

  private

  def unison_pairs
    middle_unisons.map(&:notes).compact
  end

  def middle_unisons
    middle_intervals.select { |interval| interval.perfect_consonance? && interval.unison? }
  end

  def middle_intervals
    [harmonic_intervals[1..-2]].flatten.compact
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
head_music-4.0.1 lib/head_music/style/guidelines/no_unisons_in_middle.rb
head_music-4.0.0 lib/head_music/style/guidelines/no_unisons_in_middle.rb
head_music-3.0.1 lib/head_music/style/guidelines/no_unisons_in_middle.rb
head_music-3.0.0 lib/head_music/style/guidelines/no_unisons_in_middle.rb
head_music-2.0.1 lib/head_music/style/guidelines/no_unisons_in_middle.rb
head_music-2.0.0 lib/head_music/style/guidelines/no_unisons_in_middle.rb
head_music-1.0.0 lib/head_music/style/guidelines/no_unisons_in_middle.rb
head_music-0.29.0 lib/head_music/style/guidelines/no_unisons_in_middle.rb
head_music-0.28.0 lib/head_music/style/guidelines/no_unisons_in_middle.rb