Sha256: f4c7aa9e48723f5e7f161da7327bf4c6ea36bc8de66012f01c69de93c6f5bad3

Contents?: true

Size: 585 Bytes

Versions: 9

Compression:

Stored size: 585 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::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-0.17.0 lib/head_music/style/annotations/no_unisons_in_middle.rb
head_music-0.16.2 lib/head_music/style/annotations/no_unisons_in_middle.rb
head_music-0.16.0 lib/head_music/style/annotations/no_unisons_in_middle.rb
head_music-0.14.8 lib/head_music/style/annotations/no_unisons_in_middle.rb
head_music-0.14.7 lib/head_music/style/annotations/no_unisons_in_middle.rb
head_music-0.14.5 lib/head_music/style/annotations/no_unisons_in_middle.rb
head_music-0.14.4 lib/head_music/style/annotations/no_unisons_in_middle.rb
head_music-0.14.2 lib/head_music/style/annotations/no_unisons_in_middle.rb
head_music-0.14.1 lib/head_music/style/annotations/no_unisons_in_middle.rb