Sha256: eae2c5a715280a8539626ff70636c2ed3ee6605e15198b7fdd673ceb71d59694

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::AtLeastEightNotes < HeadMusic::Style::Annotation
  MINIMUM_NOTES = 8

  def message
    "Write at least eight notes."
  end

  def marks
    placements.empty? ? no_placements_mark : deficiency_mark
  end

  private

  def no_placements_mark
    return Style::Mark.new(
      HeadMusic::Position.new(composition, "1:1"),
      HeadMusic::Position.new(composition, "2:1"),
      fitness: HeadMusic::PENALTY_FACTOR**MINIMUM_NOTES
    )
  end

  def deficiency_mark
    deficiency = [MINIMUM_NOTES - notes.length, 0].max
    if deficiency > 0
      Style::Mark.for_all(placements, fitness: HeadMusic::PENALTY_FACTOR**deficiency)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
head_music-0.11.4 lib/head_music/style/annotations/at_least_eight_notes.rb