Sha256: 7c2dfd4592a8d7c2d9c666ade3b875aff97ae41469c05cb32213041092778991

Contents?: true

Size: 928 Bytes

Versions: 21

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true

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

# A counterpoint guideline
class HeadMusic::Style::Guidelines::SingableIntervals < HeadMusic::Style::Annotation
  PERMITTED_ASCENDING = %w[PU m2 M2 m3 M3 P4 P5 m6 P8].freeze
  PERMITTED_DESCENDING = %w[PU m2 M2 m3 M3 P4 P5 P8].freeze

  MESSAGE = 'Use only PU, m2, M2, m3, M3, P4, P5, m6 (ascending), P8 in the melodic line.'

  def marks
    melodic_intervals.reject { |interval| permitted?(interval) }.map do |unpermitted_interval|
      HeadMusic::Style::Mark.for_all([unpermitted_interval.first_note, unpermitted_interval.second_note])
    end
  end

  private

  def permitted?(melodic_interval)
    whitelist_for_interval(melodic_interval).include?(melodic_interval.shorthand)
  end

  def whitelist_for_interval(melodic_interval)
    melodic_interval.ascending? ? PERMITTED_ASCENDING : PERMITTED_DESCENDING
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

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