Sha256: 426d129e4f4dab1ddbf5db645f9d978653828951156774aa74117969699446f2

Contents?: true

Size: 641 Bytes

Versions: 10

Compression:

Stored size: 641 Bytes

Contents

module HeadMusic::Style::Annotations
end

class HeadMusic::Style::Annotations::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
    if notes.length < MINIMUM_NOTES
      HeadMusic::Style::Mark.for_all(placements, fitness: notes.length.to_f / MINIMUM_NOTES)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
head_music-0.17.0 lib/head_music/style/annotations/at_least_eight_notes.rb
head_music-0.16.2 lib/head_music/style/annotations/at_least_eight_notes.rb
head_music-0.16.0 lib/head_music/style/annotations/at_least_eight_notes.rb
head_music-0.14.8 lib/head_music/style/annotations/at_least_eight_notes.rb
head_music-0.14.7 lib/head_music/style/annotations/at_least_eight_notes.rb
head_music-0.14.5 lib/head_music/style/annotations/at_least_eight_notes.rb
head_music-0.14.4 lib/head_music/style/annotations/at_least_eight_notes.rb
head_music-0.14.2 lib/head_music/style/annotations/at_least_eight_notes.rb
head_music-0.14.1 lib/head_music/style/annotations/at_least_eight_notes.rb
head_music-0.13.2 lib/head_music/style/annotations/at_least_eight_notes.rb