Class: HeadMusic::Style::Guidelines::MaximumNotes
- Inherits:
-
Annotation
- Object
- Annotation
- HeadMusic::Style::Guidelines::MaximumNotes
show all
- Defined in:
- lib/head_music/style/guidelines/maximum_notes.rb
Overview
Flags a melody with more than the allowed number of notes.
Configure the threshold with the factory, e.g. MaximumNotes.with(14).
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.with(maximum) ⇒ Object
7
8
9
|
# File 'lib/head_music/style/guidelines/maximum_notes.rb', line 7
def self.with(maximum)
super(maximum: maximum)
end
|
Instance Method Details
#marks ⇒ Object
11
12
13
|
# File 'lib/head_music/style/guidelines/maximum_notes.rb', line 11
def marks
HeadMusic::Style::Mark.for_each(notes[maximum..]) if overage.positive?
end
|
#maximum ⇒ Object
21
22
23
|
# File 'lib/head_music/style/guidelines/maximum_notes.rb', line 21
def maximum
options.fetch(:maximum)
end
|
#message ⇒ Object
15
16
17
|
# File 'lib/head_music/style/guidelines/maximum_notes.rb', line 15
def message
"Write up to #{maximum.humanize} notes."
end
|
#overage ⇒ Object
25
26
27
|
# File 'lib/head_music/style/guidelines/maximum_notes.rb', line 25
def overage
[notes.length - maximum, 0].max
end
|