Sha256: c3dc8c6baca99c7bca25dc8d3ee83a280529475ae3aec0b7992e0a84c1e66929

Contents?: true

Size: 731 Bytes

Versions: 18

Compression:

Stored size: 731 Bytes

Contents

# frozen_string_literal: true

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

# A counterpoint guideline
class HeadMusic::Style::Guidelines::AtLeastEightNotes < HeadMusic::Style::Annotation
  MINIMUM_NOTES = 8

  MESSAGE = 'Write at least eight notes.'

  def marks
    placements.empty? ? no_placements_mark : deficiency_mark
  end

  private

  def no_placements_mark
    HeadMusic::Style::Mark.new(
      HeadMusic::Position.new(composition, '1:1'),
      HeadMusic::Position.new(composition, '2:1'),
      fitness: 0
    )
  end

  def deficiency_mark
    return unless notes.length < MINIMUM_NOTES

    HeadMusic::Style::Mark.for_all(placements, fitness: notes.length.to_f / MINIMUM_NOTES)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

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