Class: HeadMusic::Style::Guidelines::MaximumNotes

Inherits:
Annotation
  • Object
show all
Defined in:
lib/head_music/style/guidelines/maximum_notes.rb

Overview

Flags a melody with more than the allowed number of notes. Configurable via the maximum: option; subclasses may set a MAXIMUM_NOTES default.

Direct Known Subclasses

UpToFourteenNotes

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from HeadMusic::Style::Annotation

Instance Method Details

#marksObject



7
8
9
# File 'lib/head_music/style/guidelines/maximum_notes.rb', line 7

def marks
  HeadMusic::Style::Mark.for_each(notes[maximum..]) if overage.positive?
end

#maximumObject (private)



17
18
19
# File 'lib/head_music/style/guidelines/maximum_notes.rb', line 17

def maximum
  options.fetch(:maximum) { self.class::MAXIMUM_NOTES }
end

#messageObject



11
12
13
# File 'lib/head_music/style/guidelines/maximum_notes.rb', line 11

def message
  "Write up to #{maximum.humanize} notes."
end

#overageObject (private)



21
22
23
# File 'lib/head_music/style/guidelines/maximum_notes.rb', line 21

def overage
  [notes.length - maximum, 0].max
end